Since I always try to remember what this code is, and I can never remember, I thought I’d add it to my blog so I never forget. 🙂

This searches a string of text and finds a user defined variable. Very handy.

$string = "PHP";
$container = "I love writing PHP code.";

if(strstr($container,$string)) {
echo "found it.";
} else {
echo "not found.";
}

Advertisements