0

在我的输出代码中是:

Array ( 
    [0] => 53,67,70
    [1] => 48 
    [2] => 11,22,13 
);

我希望输出为:array(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数据)

第 1 行: ["11,22,13"]
第 2 行: ["48"]
第 3 行: ["53,67,70"]

必须如何将输出的 php 代码固定为array(11,22,13,48,53,67,70)

4

2 回答 2

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;
于 2013-02-17T10:29:35.460 回答
0
$array = array (array (53, 67, 70), array (48), array (11, 22, 13));
$combined_array = call_user_func_array ('array_merge', $array);
于 2013-02-17T10:32:50.080 回答