vcivilen Posted March 10, 2008 Share Posted March 10, 2008 I have two arrays: $arr1 = {1,2,3,4,5,6,7,8} $arr2 = {0,3,9,10,12,14,16} How can I find the same value between them and return the ouput array: $outputarr = {3,9} ----------- Other problems: Two string $str1 = "1,2,3,4,5,6,7,8"; $str2 = "0,3,9,10,12,14,16"; how can I get $stroutput = "3,9"; ------------ I think can be use "for" or "while..do.."... but is there any quicker method ? Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 10, 2008 Share Posted March 10, 2008 http://us.php.net/in_array in conjunction with a foreach loop may do the trick. Quote Link to comment Share on other sites More sharing options...
vcivilen Posted March 10, 2008 Author Share Posted March 10, 2008 Thanks, but I just found other alternative method: Use: array_intersect http://us3.php.net/manual/en/function.array-intersect.php Again, Thank to charlieholder so much. 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.