我有以下內容: $get = array(trim($this->db->get_where('base', array('key' => 'courses'))->row('value'), '"[]')); //$get_2 = array('1', '2', '3'); $this->db->order_by("id", "desc"); $this->db->limit('8'); $this->db->where('status', 'active'); $this->db->where_in('id', $get); return $this->db->get('course')->result_array();在數據庫中它看起來像這樣:$get 變量在此表中進行查詢。問題是它不起作用,如果我使用$get_2它可以正常工作,這會是什么?奇怪,因為這些值與 $get 和 $get_2 完全相同。
1 回答

天涯盡頭無女友
TA貢獻1831條經驗 獲得超9個贊
也許是因為,IF $get 的輸出是 '1','2','3',失敗像這樣放入一個數組中。嘗試explode();:
$get = str_replace("'", "", trim($this->db->get_where('base', array('key' => 'courses'))->row('value'), '"[]'));
$get_data = explode(',',$get);
//$get_2 = array('1', '2', '3');
$this->db->order_by("id", "desc");
$this->db->limit('8');
$this->db->where('status', 'active');
$this->db->where_in('id', $get_data);
return $this->db->get('course')->result_array();
現在,它變成了 $get_data 中的數組,您可以通過 $get_data[ 訪問它數組索引];
- 1 回答
- 0 關注
- 126 瀏覽
添加回答
舉報
0/150
提交
取消