首页 > 代码库 > PHP array_search

PHP array_search

1.函数的作用:在数组中查找元素

2.函数的参数:

  @params mixed  $needle

  @params array $haystack

  @params bool $strict

3.例子:

 1 <?php
 2 $arr = [
 3     ‘a‘ => [
 4         ‘a‘ => 1,
 5         ‘b‘ => 2,
 6     ],
 7     ‘b‘ => [
 8         ‘a‘ => 3,
 9         ‘b‘ => 4,
10     ],
11 ];
12 var_dump(array_search(‘3‘,array_column($arr,‘a‘)));

 

PHP array_search