How PHP uses array_column to return the value of a single column in the input array
This article is about how PHP uses array_column to return the value of a single column in the input array. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Array_column returns the value of a single column in the input array.
Similar functions are
ArrayHelper::index in 1 Yii2 ($array, 'id')
$query- > select (['last_name',' id'])-> indexBy ('id')-> column () in 2 Yii2
/ / the array $a = array may be returned from the database ('id' = > 5698,' first_name' = > 'Peter',' last_name' = > 'Griffin',), array (' id' = > 4767, 'first_name' = >' Ben', 'last_name' = >' Smith',), array ('id' = > 3809,' first_name' = > 'Joe',' last_name' = > 'Doe',)) $last_names = array_column ($a, 'last_name',' id'); print_r ($last_names)
Output result:
Array
(
[5698] = > Griffin
[4767] = > Smith
[3809] = > Doe
)
Thank you for reading! This is the end of this article on "how PHP uses array_column to return the value of a single column in the input array". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!