How to add array elements in two dimensions in php

藏色散人
Release: 2023-03-09 18:04:02
Original
4397 people have browsed it

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".

How to add array elements in two dimensions in php

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);
        });
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template