把容易的二维数组变成一维数组

WBOY
Release: 2016-06-13 12:23:07
Original
1121 people have browsed it

把简单的二维数组变成一维数组

在工作中我们经常需要把二维数组变成一维数组。那么就需要循环拿出来,其实有时候我们可以使用一些小技巧,借助php的内置函数来实现,但是我说的只是简单的二维数数组$arr= array('name'=>array('a'=>'abc','b'=>'bcd','c'=>'cde'));如果我们使用array_pop(),就可以拿到一维数组了,array_pop()本来是删除并返回数组的最后一个元素。

所以我们就可以将上诉的$arr变成array('a'=>'abc','b'=>'bcd','c'=>'cde'),这样就把二维数组变成一维数组了,但是仅限于二维数组中是一个一维数组,如果是多个一维数组的话就会返回最后一个数组了。

 

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!