[wd_asp elements=’search’ ratio=’100%’ id=1]

Check if PHP variable contains specific text

23rd December 2014

Php - Strings

php codehaven

If you want to check that a PHP variable contains specific text, then this code could be useful.

Please note: that it is case specific. If you are searching for ‘DOG’ and you have found ‘dog’ it will not trigger successfully.
You will need this script to make the PHP variable to lowercase.

if (strpos($myvar,'are') !== false) {
echo 'true';
}