在PHP中如何判断一个数组是否存在于二维数组中?


在数组中判断 {"name" => 3333, "id" => 3} 是否存在二维数组中。

   
  $a = {
  
0 => {"name" => 1111, "id" => 1},
1 => {"name" => 2222, "id" => 2},
2 => {"name" => 3333, "id" => 3},
3 => {"name" => 4444, "id" => 4},
4 => {"name" => 5555, "id" => 3}
}

@magic 的答案可以实现, @打酱油的 的适合于判断是否包含这两个字段

php actionscript as3 JavaScript

stank 12 years, 1 month ago

为啥不直接用in_array函数?
手册里的定义:

   
  bool in_array ( mixed $needle , array $haystack [, bool $strict ] )
 

店长SAMA answered 12 years, 1 month ago

Your Answer