Friday, September 19, 2008

The strstr() function

This function is used to identify the position of a string within a larger string.
If our search string is not found, this function returns FALSE.

Syntax: strstr(string,search string);

search string – the sub-string that is to be searched in the larger string.

Example input:

$str1="This is a simple PHP program";
echo $str1;
echo "
";
echo strstr($str1,"PHP");
echo "
";
echo strstr($str1,"p");

Example output:

This is a simple PHP program PHP program ple PHP program

No comments: