array('Satzteile', 'viverra'), 1 => array('auctor', 'eigenes'), 2 => array('hinaus', 'sagittis'), 3 => array('Quisque', 'herkäme'), 4 => array('große', 'nunc') ); for($i = 0; $i < 10000; $i++) { $random_value = rand(0, 4); $needles = $needles_container[$random_value]; // check if one of the needles is found in haystack (using stripos) $found = false; foreach($needles as $needle) { if(stripos($haystack, $needle) !== false) { $found = true; break; } } /* // check if one of the needles is found in haystack (using preg_match) $found = false; $needle = implode('|', $needles); if(preg_match('/'.$needle.'/is', $haystack) == 1) { $found = true; } */ } // we're done echo 'all done...'; ?>