PHP Find Variable in a String

Saturday, 4th July 2009

Since I’ve search the web for this answer twice already today 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.

<?php
    $string = "PHP";
    $container = "Where are you?";
    if(strstr($container,$string)) {
        echo "found it.";
    } else {
        echo "not found.";
    }
?>

Tags: