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. 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"; ?> 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. 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
Archived
This topic is now archived and is closed to further replies.