$find_letters = array('a', 'c', 'd');$string = 'abcdefg';if(strpos($string, $find_letters) !== false){
echo 'All the letters are found in the string!';}
下面的代码不仅展示了如何做到这一点,而且还将它放在一个易于使用的功能中。它是由“jesda”编写的。(我在网上找到了)PHP代码:<?php/* strpos that takes an array of values to match against a string * note the stupid argument order (to match strpos) */function strpos_arr($haystack, $needle) { if(!is_array($needle)) $needle = array($needle); foreach($needle as $what) { if(($pos = strpos($haystack, $what))!==false) return $pos; } return false;}?>用法:$needle = array('something','nothing');$haystack = "This is something";echo strpos_arr($haystack, $needle); // Will echo True$haystack = "This isn't anything";echo strpos_arr($haystack, $needle); // Will echo False