For example I have a string I am @ the penthouse.
I need to know how to find the character “@” in php string and the position of the character.
I tried strpos but its not working.
Thanks for the help in advance.
EDIT:
I’ve been using this for get the character:
$text = "I am @ the penthouse";
$pos = strrpos($text, '@');
if($pos == true)
{
echo "yes";
}
I would do this
Note, I’m using
strpos, not reverse counterpart,strrposNote: Because
@could be the first character in a string,strposcould return a0. Consider the following:So,
strposwill explicitly returnfalsewhen no match is found. This is how to properly check for a substring position: