How to check if a substring exists in a string in PHP
Having a string:
$mystring = 'teststringforme';
I want to know if, for example, 'for' exists in $mystring. Using PHP function strpos, it's very easy.
if( strpos( $mystring, 'for' ) !== false )
{
echo 'string exists';
}
else
{
echo 'string does not exist';
}
1 comment:
Awesome
Post a Comment