Removing the keys from result_array() |
[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!
[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
[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.
[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). ![]() |
Welcome Guest, Not a member yet? Register Sign In |