I have this code in Codeigniter, but somehow array_merge does not want to work, how is it possible to merge array to the result?
$categories = $this->get_categories();
$data = array();
foreach ($categories as $index) {
$this->db->select('*');
$this->db->from('questions');
$this->db->where('category', $index);
$this->db->order_by('id','RANDOM');
$this->db->limit(3);
$query = $this->db->get();
array_merge_recursive($data, $query->result());
}
return $data;
您需要将array_merge_recursive()
的结果保存到$data
字符串中:
$data = array_merge_recursive($data, $query->result());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.