Welcome Guest, Not a member yet? Register   Sign In
Removing the keys from result_array()
#1

[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();
return $query->result_array()
... produces an array with "id" as the key. But I'd like to return a flat array like: array(3,5,8,12,etc)

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();
foreach($query->result_array() as $result){
  $myarray[] = $result['id'];
}

Thanks!


Messages In This Thread
Removing the keys from result_array() - by El Forum - 05-04-2011, 09:46 AM
Removing the keys from result_array() - by El Forum - 05-04-2011, 09:57 AM
Removing the keys from result_array() - by El Forum - 05-04-2011, 09:59 AM
Removing the keys from result_array() - by El Forum - 05-04-2011, 01:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB