find a word in string php code example
Example 1: find in php string or
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}
Example 2: get specific word from string php
$myString = "input/name/something";
$strArray = explode('/',$myString);
$name = $strArray[1];
$something = $strArray[2];
Example 3: php check if string contains
// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}