php method to add array elements in two dimensions: first create a two-dimensional array "$consult"; then append the elements of "$arr" to the front of "$consult".
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
php appends elements to a two-dimensional array, php two Method of adding array elements to the dimension
Previous data processing:
After processing:
//$consult 为往里插之前的数组 //把$arr的元素追加到$consult的最前面 $arr = []; $arr[0]['workplaceId'] = '0'; $arr[0]['workplaceName'] = '信息部'; $arr[0]['List'] = [['typeId' => 3, 'typeName' => '全部']]; array_walk($arr,function($item) use (&$consult) { array_unshift($consult, $item); });
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to add array elements in two dimensions in php. For more information, please follow other related articles on the PHP Chinese website!