The content of this article is about PHP getting the specified value position in the array. It has a certain reference value. Now I share it with you. Friends in need can refer to it
<?php //定义一个数组 $array = array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'); //使用 array_search('要搜索的值',数组); $key = array_search('b', $array); // $key = 1; $key = array_search('a', $array); // $key = 0; ?>
Related recommendations:
PHP Gets the number of the specified value in the multi-dimensional array. Column
PHP method to get last week, this week, last month, this month, this quarter, and last quarter time
The above is the detailed content of PHP gets the specified value position in the array. For more information, please follow other related articles on the PHP Chinese website!