php merge arrays

前端 未结 6 1658
北海茫月
北海茫月 2021-01-21 08:33

I have been trying (unsuccessfully) to merge the output of multiple arrays into a single array. An example of what I tried was:

$data1 = array(\"cat\", \"goat\")         


        
6条回答
  •  礼貌的吻别
    2021-01-21 08:55

    You could add the items to a new array sequentially to achieve your desired result:

    :
    $aResult = array();
    foreach ($lines as $inner) {
        $item = array($inner[1]);
        $aResult[] = $item;
    }
    var_dump($aResult);
    

提交回复
热议问题