string strstr(string text, string substring)
The strstr function returns the portion of the text argument from the first occurrence
of the substring argument to the end of the string. If substring is not a string, it is
assumed to be an ASCII code. ASCII codes are listed in Appendix B.
An empty string is returned when substring is not found in text. You can use it as a
faster alternative to ereg if you test for an empty string, as in the example below. The
stristr function is a case-insensitive version of this function.
<?
$text = "Although this is a string, it's not very
long.";
if(strstr($text, "it") != "")
{
print("The string contains 'it'.BR>/n");
}
?>
string strtok(string line, string separator)
The strtok function pulls tokens from a string. The line argument is split up into
tokens separated by any of the characters in the separator string. The first call to
strtok must contain two arguments. Subsequent calls are made with just the
separator argument, unless you wish to begin tokenizing another string. Chapter
16, "Parsing and String Evaluation," discusses this function in depth, including
alternatives like ereg.
<?
// create a demo string
$line = "leon\tatkinson\[email protected]";
// loop while there are still tokens
for($token = strtok($line, "\t");
$token != "";
$token = strtok("\t"))
{
print("token: $tokenBR>\n");
}
?>