在我的输出代码中为:
Array (
[0] => 53,67,70
[1] => 48
[2] => 11,22,13
);
我希望输出为:数组(11,22,13,48,53,67,70)
$result = $this->db->get_where('table',array('mainpage'=>$mp'));
$data = array();
$out = array();
foreach($result->result() as $row){
$dv = json_decode($row->subpage);
$out = array_merge($dv, $out);
}
return $out;
在我的数据库表中,行如下:(json data)
第1行: [" 11,22,13"]
第2行: [" 48"]
第3行: [" 53,67,70"]
如何将输出的PHP代码修改为array(11,22,13,48,53,67,70)
?
答案 0 :(得分:0)
$result = $this->db->get_where('table',array('mainpage'=>$mp));
$data = array();
$out = array();
foreach($result->result() as $row){
$dv = json_decode($row->subpage);
$flat = array();
foreach ( $dv as $item ) {
$flat = array_merge( $flat, explode( ',', $item ) );
}
$out = array_merge( $out, $flat );
}
return $out;
答案 1 :(得分:0)
$array = array (array (53, 67, 70), array (48), array (11, 22, 13));
$combined_array = call_user_func_array ('array_merge', $array);