Home >Backend Development >PHP Tutorial >Turn a simple two-dimensional array into a one-dimensional array, a two-dimensional array and a two-dimensional array_PHP tutorial
In work, we often need to convert a two-dimensional array into a one-dimensional array. 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-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.