array_column:将一个多维数组的转换为一个键值对数组
Jun 06, 2016 pm 07:39 PMarray_column(array$input,$column_key,$index_key) 第一个参数为原始数组,第二个参数(多维数组键名)为新数组的值,第三个参数(多维数组键名)为键.结果为一个键值对数组 $array = [['id' = 1,'name' = 'tom','age' = 18],['id' = 2,'name' = 'jack','age' = 1
array_column( array $input , $column_key , $index_key)
第一个参数为原始数组,第二个参数(多维数组键名)为新数组的值,第三个参数(多维数组键名)为键.结果为一个键值对数组
$array = [ ['id' => 1,'name' => 'tom','age' => 18], ['id' => 2,'name' => 'jack','age' => 19], ['id' => 3,'name' => 'mick','age' => 20], ['id' => 4,'name' => 'lucy','age' => 21], ['id' => 5,'name' => 'bill','age' => 22], ]; $arr = array_column($array,'name','id'); echo '<pre class="brush:php;toolbar:false">'; print_r($arr); result: Array ( [1] => tom [2] => jack [3] => mick [4] => lucy [5] => bill )

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

XREAL founder Xu Chi: Apple lets everyone see the future of spatial computing, and we work hard to let everyone see the present of spatial computing.

How to remove duplicate elements from PHP array using foreach loop?

NTT QONOQ Devices unveils Mirza wireless XR glasses for smartphones

PHP array key value flipping: Comparative performance analysis of different methods

PHP array multi-dimensional sorting practice: from simple to complex scenarios

The Art of PHP Array Deep Copy: Using Different Methods to Achieve a Perfect Copy

Christie: dual drive of technology + innovation brings unlimited possibilities

Application of PHP array grouping function in data sorting
