php - how to find empty values in array -


i working on create comparison of college completed want find empty values , put strike instead of empty column know can using if statements seeking there better way other using nested if else or multiple if

controller has function select value

public function test()     {         $insid  = "ins20160738";         $course = "b.tech electronics & communication engineering";         $this->load->model('comparisonmodel');             $resfirst   = $this->comparisonmodel->selfirst($insid,$course);             foreach ($resfirst $key => $value) {                 echo '<h6> name:</h6><p>'.$value['course_name'].'</p><h6>duration:</h6>'.$value['duration'].'                      <h6>eligiblity:</h6><p>'.$value['eligibility'].'</p><h6>recognition:</h6><p>'.$value['recognition'].'</p><h6>affiliation:</h6>'.$value['affiliation'].'                      <h6>certification:</h6>'.$value['certificate'].'<h6>category:</h6>'.$value['category'].'<h6>type:</h6>'.$value['type'].'<h6>category:</h6>'.$value['school_batch'].'';             }     } 

model selecting is

public function selfirst($insid,$course)   {     $stmt='select * `institute-course` `institute-id`=  '.$this->db->escape($insid).' , `course_name`='.$this->db->escape($course);     $res=$this->db->query($stmt);     return $res->result_array();   } 

i result this

name:  b.tech electronics & communication engineering  duration:  eligiblity:  plus 2  recognition:  affiliation:  p j abdul kalam technological university certification:  b.tech in electronics & communication engineering category:  under graduate type:  college category: 

what searching there better way result this

name:  b.tech electronics & communication engineering  duration: field empty or put strike   eligiblity:  plus 2  recognition:this field empty  affiliation:  p j abdul kalam technological university certification:  b.tech in electronics & communication engineering category:  under graduate type:this filed empty college category: field empty 

with out using multiple if else statements

thanks in advance

in foreach loop try (controller)

foreach ($resfirst $value)  { ?>     <h6> name:</h6>         <p> <?= (empty($value['course_name'])) ? 'this field empty' : $value['course_name'] ; ?> </p>     <h6> duration:</h6>         <p> <?= (empty($value['duration'])) ? 'this field empty' : $value['duration'] ;?> </p>     <h6> eligiblity:</h6>         <p> <?= (empty($value['eligiblity'])) ? 'this field empty' : $value['eligiblity'] ;?> </p>     <h6> recognition:</h6>         <p> <?= (empty($value['recognition'])) ? 'this field empty' : $value['recognition'] ;?> </p>     <h6> affiliation:</h6>         <p> <?= (empty($value['affiliation'])) ? 'this field empty' : $value['affiliation'] ; ?> </p>     <h6> certification:</h6>         <p> <?= (empty($value['certificate'])) ? 'this field empty' : $value['certificate'] ; ?> </p>     <h6> category:</h6>         <p> <?= (empty($value['category'])) ? 'this field empty' : $value['category'] ; ?> </p>     <h6> type:</h6>         <p> <?= (empty($value['type'])) ? 'this field empty' : $value['type'] ; ?> </p>     <h6> category:</h6>         <p> <?= (empty($value['school_batch'])) ? 'this field empty' : $value['school_batch'] ; ?> </p> <?php } 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -