PHP- I need to compare two arrays and find the values that match between them

Say i have 2 arrays
array 1 = 0-45, 1-14, 2-16, 3-25, 4-99

array 2 = 0-16 1-15 2-67 3-45 4-88

Is there a simple PHP function to return which values match in another array? In this case a comparative array that returns

0-16
1-45

since both arrays have those values?

Thanks!

LVL 10
stormistAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zreakCommented:
array_intersect() returns an array containing all the values of array1 that are present in all the arguments. Note that keys are preserved.

Example 227. array_intersect() example

<?php
$array1 = array("a" => "green", "red", "blue");
$array2 = array("b" => "green", "yellow", "red");
$result = array_intersect($array1, $array2);
?>

This makes $result have

<?php Array
(
   [a] => green
   [0] => red
) ?>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stormistAuthor Commented:
Hi all! What would be a way to use that function but reset the keys? first one 0 , 2nd one 1. etc?

Thx!
0
ravenplCommented:
Use: http://pl2.php.net/manual/en/function.array-values.php
on the resulted array. Resulting array would be indexed by numbers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.