unrelenting Posted December 29, 2008 Share Posted December 29, 2008 I can't figure out how to do this. I have an array for example: $colors = array("red", "green", "blue", "orange", "purple", "yellow"); I have used in_array in the past to do this for a single value but what if I am wanting to check is if red, orange, AND yellow all show up in the array somewhere? How would I do that? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/138694-solved-searching-for-multiple-values-in-an-array/ Share on other sites More sharing options...
MadTechie Posted December 29, 2008 Share Posted December 29, 2008 <?php $colors = array("red", "green", "blue", "orange", "purple", "yellow"); $find = array("red", "orange", "yellow"); $found = count($find); //3 foreach($find as $f) { if(in_array($f, $colors)) { found--; } } if(found==0) echo "Found all"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/138694-solved-searching-for-multiple-values-in-an-array/#findComment-725134 Share on other sites More sharing options...
unrelenting Posted December 29, 2008 Author Share Posted December 29, 2008 That worked perfectly. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/138694-solved-searching-for-multiple-values-in-an-array/#findComment-725393 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.