Hi im wondering if anyone could shed light on how to do this. I have an array below: Array ( [0] => stdClass Object ( [id] => 1 [cat_name] => Doo Range ) [1] => stdClass Object ( [id] => 2 [cat_name] => Com Range ) [2] => stdClass Object ( [id] => 3 [cat_name] => Master Range ) ) I need to loop through and pick out all cat names, at the moment using the code I have only returns one cat name. $query = $this->db->query("SELECT * FROM fuel_product_cats"); foreach($query->result() as $rows) { $options = array($rows->id => $rows->cat_name); } // Check the array print_r($options); ### ONLY ONE CAT NAME APPEARS IN THE ARRAY, NOT ALL 3 LIKE I WANT Thanks in advance.
foreach($query as $rows) { $options = array($rows->id => $rows->cat_name); } PHP: This should work, if not, print_r your query before the array