Im using this query:
$lang
is like this Array ( [0] => Afrikaans [1] => English )
$this->db->select('id');
$this->db->from('language');
$this->db->where_in('language',$lang);
$query = $this->db->get();
$l_id =$query->result_array();
For this query, when I use print_r($l_id)
Im getting an output like this:
Array ( [0] => Array ( [id] => 1 ) [1] => Array ( [id] => 21 ) )
But I need something like this:
Array ( [0] => 1 [1] => 21 )
Someone please help me to do this. Thanks
Try like this...
$this->db->select('id');
$this->db->from('language');
$this->db->where_in('language',$lang);
$query = $this->db->get();
$l_id =$query->result_array();
foreach($l_id as $key=>$value)
{
$ids[] = $value['id'];
}
print_r($ids);
For example:
$l_id = array(array('id'=>'1'),array('id'=>21));
//print_r($l_id);
foreach($l_id as $key=>$value)
{
$ids[]=$value['id'];
}
print_r($ids);
Replace:
$l_id =$query->result_array();
With:
$l_id =$query->result();
OR try
$l_id =$query->row();
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.