Forum Moderators: coopster
I've a text with an expresssion and I want to test if there is a specific expression in this text.
For example :
$text = 'blahblahblibli';
if (?) // if there is "blahblah" in $text
{
do this ();
}
So, I'm looking for a php function to test if there is an expression in a text. I don't know it but that might exists, isn't it :-?
that work, but if I make this that doesn't :if ($pos === true) {
echo "OK!";
}
else {}
Isn't it weird?
Not weird. strpos() returns false if the string is not found, and the character number of the start of the substring if it is found.
Assuming the string is found, then there will be some number returned (not true), so:
$pos === true << fails
What you mean is:
if ($pos!== false)