I'm looking for some wildcards to the strpos
function similar to those used in preg_replace
or preg_match
but I can't find any, here is an idea:
<?php
if (strpos("The black\t\t\thorse", "black horse") === false)
echo "Text NOT found.";
else
echo "Text found.";
?>
Here the result will be: Text NOT found.
Now I want to use one wildcard to omit spaces or horizontal tab like below:
<?php
if (strpos("The black\t\t\thorse", "black/*HERE THE WILDCARD*/horse") === false)
echo "Text NOT found.";
else
echo "Text found.";
?>
And here the idea is that the result is: Text found.
Does anyone know something about ?
strpos() doesn't match patterns, if you want to match patterns you have to use preg_match() this should work for your situation.
<?php
if (preg_match('/black[\s]+horse/', "The black\t\t\thorse"))
echo "Text found.";
else
echo "Text not found.";
?>