Is there a better way to get the same result that this produces?
foreach($data['report']->result_array() as $k){
$array[] = $k['id'];
}
Better: in this context, meaning shorter, easier to read, or better syntax overall.
I’m a noob, so comments/suggestions/general wisdom from the programming community is welcome!
I can’t think of a better way to achieve this.
Of course, if you are able to alter the result_array() function you can introduce a new parameter to return the id field only.
However, in my opinion this decreases the readability of the code.
If you only want to load the id’s from $data[‘report’], i would suggest defining a new specialized method that returns all the id‘s.