Jason Small
Jason Small

Reputation: 1054

Find if array exists in multidimensional array

I have a multidimensional array that look like this:

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] => 
    )

)

I then have another array that looks like

   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] => 
)

Is the a way to look through the multdimensional array and see if the single array exists already in the multidimensional array?

Upvotes: 0

Views: 113

Answers (1)

Tomas Reimers
Tomas Reimers

Reputation: 3292

I believe in_array() should work.

Link to PHP manual.

In the changlog it mentions that as of 4.2.0 the needle (search) can be an array...

Upvotes: 2

Related Questions