Virajsinh

CodeIgniter row_array And result_array customize

Aug 25th, 2020
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // CodeIgniter row_array() And result_array() Customize
  2.  
  3. //row_array()
  4. $result = $query->row_array();
  5. $remove = array('created_at','updated_at'); // Remove Field Name
  6. $arr = array_diff_key($result, array_flip($remove));
  7.  
  8. //result_array()
  9. $result = $query->result_array();
  10. $newArr = array_reduce($result, function($carry, $item){
  11.     $carry[] = [
  12.         "id" => $item['id'],
  13.         "name" => $item['name'],
  14.         "status" => $item['status'],
  15.     ];
  16.     return $carry;
  17. });
RAW Paste Data