11 January, 2018

How to use Array push function

1. Data get from Database to loop in view

<?php
  $arr_values = array();  
  foreach ($amount_return->result() as $row){      
      $data_id = $row->operation_id;           
      array_push($arr_values, $data_id);  }
?>
2. Code to display in view
<?php    
    if ($row->status_return == 0){
       if(in_array($row->id, $arr_values)){
          // code to be executed or any condition
          //$row->id get another table id to compare 
           with array push get from another table also
       }
    }
?>

No comments:

Post a Comment