0

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?

1 Answer 1

2

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...

Sign up to request clarification or add additional context in comments.

3 Comments

This does not seem to work. I'm guessing because it can't search a multidimensional array. It always returns false.
@JasonSmall -- in_array is sufficient if you're only dealing with two dimensions.
@rdlowrey You are correct. I had the needle and haystack reversed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.