dsaba Posted April 24, 2007 Share Posted April 24, 2007 I have 2 arrays: $array1[] = 'hello'; $array1[] = 'how'; $array1[] = 'are'; $array1[] = 'you'; $array1[] = 'bob'; $array2[] = 'hello how'; $array2[] = 'are you steve'; I want to compare $array1 with $array2, and if any value of $array1 is found in $array2 I want to perform an action I know this has to be in a loop, i'm confused about how to set it up Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 24, 2007 Share Posted April 24, 2007 it dose'nt need a loop. $matches = array_intersect($array1,$array2); if (count($matches) > 0) { // matches found so do you stuff. print_r($matches); // print the matches just to check. } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.