Php ul li foreach group similar -


using array

array(     array('status'=>1, 'name'=>'james wah'),     array('status'=>1, 'name'=>'james weh'),     array('status'=>2, 'name'=>'james wih'),     array('status'=>2, 'name'=>'james woh'),     array('status'=>2, 'name'=>'james wuh'), ) 

how output this

  • james wah
  • james weh
  • james wih
  • james woh
  • james wuh

using single foreach() , has 2

try this, displays diff group of status :

$status = $data[0]['status']; echo "<ul>"; foreach($data $value) {     if($status != $value['status'])         echo "</ul><br /><ul>";     echo "<li>".$value['name']."</li>";     $status = $value['status']; } echo "</ul>"; 

Comments