Masroor
0
Q:

php string contains substring

$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
    echo "My string contains Bob";
}
25
$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}
2
if (strpos($string, 'substring') !== false) {
	// do stuff 
}
3
$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}
0
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
3
// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
    return strpos($haystack, $needle) !== false;
}
2

New to Communities?

Join the community