Anyone code in PHP out there. Well if so, here is a helpful hint. Ever need to find a string in an another string? Uh, or maybe find a variable in a string? If you don’t, someone sure does, well take me for instance, I do this often. Its quite simple. You use the strstr() function like so:
$string_to_find = “Patrick”;
$string_to_look_in = “Hello Patrick, what is your name?”;
if(strstr($string_to_look_in,$string_to_find)) {
echo “AHA, found it.”;
} else {
echo “hmmm… yeah, just doesn’t seem to be here right now.”;
}
Hope this was helpful to someone.
|

