Many problems will be encountered in the process of obtaining arrays. This article will explain the relevant knowledge.
PHP gets the specified value of the multi-dimensional array in which column of the array
Mainly used:
array_column array_search
<?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会输出下列字段 Array ( [0] => 1 [1] => 3 [2] => 5 )
Then get the position of the corresponding value according to the array_search function
This This article explains the relevant knowledge of obtaining arrays. For more related knowledge, please pay attention to the PHP Chinese website.
Related recommendations:
php basic learning: PHP arrays and data structures
php basic learning: PHP file system
php basic learning: image processing
The above is the detailed content of PHP gets the specified value from a multi-dimensional array in which column of the array?. For more information, please follow other related articles on the PHP Chinese website!