PHP compare two dimension array

Posted by Jerry on Stack Overflow See other posts from Stack Overflow or by Jerry
Published on 2010-05-30T02:41:04Z Indexed on 2010/05/30 2:42 UTC
Read the original article Hit count: 279

Filed under:
|
|

Hello guys I would like to know how to compare two two-dimension arrays value.

First array

Array 1
(
    [0] => Array
        (
            [0] => a
        )

    [1] => Array
        (
            [0] => b
        )

    [2] => Array
        (
            [0] => c
        )

}

Second one

Array 2
      (
            [0] => Array
                (
                    [0] => a
                )

        [1] => Array
            (
                [0] => d
            )

        [2] => Array
            (
                [0] => e
            )

    }

I need to know if my loop could compare the arrays to check the matched value. In my case, array1[0][0]=a matches array2[0][0]=a. If it matches, php will output some html.

My foreach loop

foreach ($array1 as $arrays){
    foreach($arrays as $array){
      //need to compare array2 here not sure how to do it.
}

}

I would appreciate any helps. Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about array