Miller86
0
Q:

contains php

$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';
}
0
$a = 'Hello world?';

if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
    echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
    echo 'true';
}
2
$result = strpos("haystack", "needle");

if ($result != false)
{
  // text found
}
3
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
3
if (strpos($a, 'are') !== false) {
    echo 'true';
}
1
// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
    return strpos($haystack, $needle) !== false;
}
2
//Find the position of the first occurrence of a substring in a string
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
1

New to Communities?

Join the community