to append an element to a two-dimensional array. I don"t know why I can"t append it all the time. The similar code is as follows, mainly using the function array_unshift (). In the document, it is said that elements can be appended to the array.
<?php
$arr1 = ["0"=>["name"=>zhangsan,"sex"=>1],"1"=>["name"=>lisi,"sex"=>0],"2"=>["name"=>wangwu,"sex"=>1]];
$array2 = ["0"=>["name"=>zhaoliu,"sex"=>1],"1"=>["name"=>xiaoqi,"sex"=>1]];
//$arr2$arr1
:
foreach($array2 as $key=>$value){
array_unshift($arr1,$value);
}
:
array_walk($array2,function($item) use ($arr1)){
array_unshift($arr1,$item);
}
print $arr1 with a number instead of an appended new array; ask the master to analyze the cause or give a solution, thank you.