Forum Moderators: coopster

Message Too Old, No Replies

Comparing Arrays

I want to compare 3 arrays at the same time

         

anirudha30

4:40 am on Sep 14, 2007 (gmt 0)

10+ Year Member



I have 3 arrays:

Array1
(
[0] =>
[1] => 2
[2] =>
[3] => 4
[4] => 5
)

Array2
(
[0] => 123452
[1] => 123454
)

Array3
(
[0] => 123451
[1] => 123452
[2] => 123453
[3] => 123454
[4] => 123456
)

What i want to do is to find what is the value in Array1 corresponding to the values in Array2.

anirudha30

4:42 am on Sep 14, 2007 (gmt 0)

10+ Year Member



Actually What i want is to find what is the value in Array1 corresponding to the values in Array3 & whether that value exists in Array2.
Any idea guys?

eelixduppy

5:11 am on Sep 14, 2007 (gmt 0)



Maybe something like this?:

$found = [url=http://www.php.net/array-intersect]array_intersect[/url]($array1, $array3);
$final_found = array_intersect($found,$array2);
echo '<pre>'; print_r($final_found); echo '</pre>';

anirudha30

6:51 am on Sep 14, 2007 (gmt 0)

10+ Year Member



thanks eelixduppy....