There is no built-in way to do this quickly. Your task can be accomplished in many different ways, which will differ from how complete they are. You don't mention null values ββor check string formatting, so something like this might work for your purpose:
function all_combos($str,$vals) { $s=explode("_",$str); foreach($s as $c) { if(!in_array($s,$vals)) return false; } return true; }
Call as all_combos("b_c_a",array("a","b","c"));
source share