Hello,
I wuold create a condition with multpple characters in strpos. I’ve looked up on the php documentation but I’ve not found anything about it. So, is possibile realize that?
No I do not believe strpos() allows multiple search items… but that is easy to implement. Not the most elegant… but try this:
$findMe = array('@', '/', '&', '$', '"', '!');
$string = "fdfdfdf@asdfdsf$.jfdkjfd";
echo multi_strpos($string, $findMe);
/**
* Returns position of needle, or false if not found
* @param string $haystack The string that needs searched
* @param array $needles An array of mixed values that we'll search for
* @param integer $offset Offset position of search string (Optional)
*
* @return integer|false false if not found
*/
function multi_strpos($haystack, $needles, $offset = 0) {
foreach ($needles as $n) {
if (strpos($haystack, $n, $offset) !== false)
return strpos($haystack, $n, $offset);
}
return false;
}