This article mainly introduces PHP to get the specified value of the multi-dimensional array in which column of the array. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
Mainly used:
<?php $user = array( 0 => array( 'id' => 1, 'name' => '张三', 'email' => 'zhangsan@qq.com', ), 1 => array( 'id' => 3, 'name' => '李四', 'email' => 'lisi@qq.com', ), 2 => array( 'id' => 5, 'name' => '王五', 'email' => 'wangwu@qq.com', ) ); print_r(array_column($user,'id')); ?>
print_r will output the following fields
Array
(
[0] => 1
[1] => 3
[2] => 5
)
Then get the position of the corresponding value according to the array_search function
For detailed function introduction, you can view the manual or the corresponding article
Related recommendations:
7 ways for PHP to get file extensions
php Get some time to implement the method practice
The above is the detailed content of PHP gets the column of the array where the value specified in a multi-dimensional array is. For more information, please follow other related articles on the PHP Chinese website!