Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CodeIgniter row_array() And result_array() Customize
- //row_array()
- $result = $query->row_array();
- $remove = array('created_at','updated_at'); // Remove Field Name
- $arr_list_removed = array_diff_key($result, array_flip($remove));
- //row_array()
- $allowed = array('first_name','last_name','email','gender'); // allowed Field Name
- $arr_list_allowed = array_intersect_key($result, array_flip($allowed ));
- //result_array()
- $result = $query->result_array();
- $newArr = array_reduce($result, function($carry, $item){
- $carry[] = [
- "id" => $item['id'],
- "name" => $item['name'],
- "status" => $item['status'],
- ];
- return $carry;
- });
- $array_a = ['a','b','c','d'];
- $array_b = ['e','f','a','g'];
- $result_a = array_intersect($array_a, $array_b); // Output : array('a');
- $result_b = array_diff($array_a, $array_b); // Output : array('b','c','d');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement