我有这段代码:
$query = $this->db->select( 'cat_id' )
->from( 'products_cat' )
->where('product_id',$id)
->get()
**->result_array();**
return $query;
以这种格式返回值:
Array ( [0] => Array ( [cat_id] => 2 ) [1] => Array ( [cat_id] => 3 ) [2] => Array ( [cat_id] => 5 ) )
我希望它返回像Array(2,3,5)
(没有数组内的数组且没有“cat_id”索引)
我需要改变什么?
答案 0 :(得分:0)
result_array()返回一个json_decoded数组。使用json_encode($query)