查找数组是否存在于多维数组中

时间:2012-01-19 01:36:38

标签: php

我有一个多维数组,如下所示:

Array


[1] => Array
    (
        [0] => ACURA
        [1] => CL
        [2] => 3.2L V6 F/I
        [3] => Blue
        [4] => 33-2133
        [5] => 33-2133
        [6] => V6
        [7] => F/I
        [8] => 
    )

[2] => Array
    (
        [0] => ACURA
        [1] => CL
        [2] => 3.2L V6 F/I
        [3] => Blue
        [4] => PS-1004
        [5] => PS-1004
        [6] => V6
        [7] => F/I
        [8] => 
    )

然后我有另一个看起来像

的数组
   Array
(
    [0] => ACURA
    [1] => CL
    [2] => 3.2L V6 F/I
    [3] => blue
    [4] => HP-1004
    [5] => HP-1004
    [6] => V6
    [7] => F/I
    [8] => 
)

是一种查看多维数组并查看单个数组是否已存在于多维数组中的方法吗?

1 个答案:

答案 0 :(得分:2)

我相信in_array()应该有用。

Link to PHP manual.

在changlog中它提到从4.2.0开始,针(搜索)可以是一个数组......