![]() |
Removing the keys from result_array() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Removing the keys from result_array() (/showthread.php?tid=41324) |
Removing the keys from result_array() - El Forum - 05-04-2011 [eluser]matula[/eluser] This is probably a simple task, but I want to generate a single-level array from a resultset. This code: Code: $query = $this->db->select('id')->from('table')->get(); Is there a way to do that in CI or PHP, or will I need to just loop through the array and create it myself like: Code: $myarray = array(); Thanks! Removing the keys from result_array() - El Forum - 05-04-2011 [eluser]jwburnside[/eluser] I believe PHP has a function to cover you there, called array_values(): http://php.net/manual/en/function.array-values.php Removing the keys from result_array() - El Forum - 05-04-2011 [eluser]jwburnside[/eluser] Actually, I'm sorry, I misunderstood the question. That will just create numerical keys. As far as I know you will have to loop through to array to get what you want. Removing the keys from result_array() - El Forum - 05-04-2011 [eluser]Coode[/eluser] This is something I didn't try out myself, but give it a shot! Code: <?php The variable would be array(1, 2, 3, 4). ![]() |