I have variable $mystring = "abc+adb"
and I am trying to find ab in the $mystring
. I want to throw a message which say ab does not exist in $mystring
, but the following code keeps picking ab from abc, I want ab to be treated as a standalone substring;
$mystring = 'abc+adb';
$findme = 'bc';
$pos = strpos($mystring, $findme);
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
}
else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}