Home > Backend Development > PHP Tutorial > Convert a simple two-dimensional array into a one-dimensional array

Convert a simple two-dimensional array into a one-dimensional array

WBOY
Release: 2016-08-08 09:20:42
Original
1369 people have browsed it

In our work, we often need to convert two-dimensional arrays into one-dimensional arrays. Then we need to loop it out. In fact, sometimes we can use some tricks to achieve it with the help of PHP's built-in functions, but what I'm talking about is just a simple two-dimensional array $arr= array('name'=>array(' a'=>'abc','b'=>'bcd','c'=>'cde')); If we use array_pop(), we can get a one-dimensional array, array_pop() Originally deletes and returns the last element of the array.

So we can change the $arr of the appeal into array('a'=>'abc','b'=>'bcd','c'=>'cde'), so that the two The dimensional array becomes a one-dimensional array, but only if the two-dimensional array is a one-dimensional array. If there are multiple one-dimensional arrays, the last array will be returned.

The above has introduced how to turn a simple two-dimensional array into a one-dimensional array, including all aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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