PHP的字符串标记生成器

I have used the String Tokenizer in Java. I wish to know if there is similar functionality for PHP. I have a string and I want to extract individual words from it.

eg. If the string is -

Summer is doubtful #haiku #poetry #babel

I want to know if it contains the hashtag #haiku.

strpos, stripos, strstr, stristr are easy solutions.

strpos example:

$haikuIndex = strpos( $str, '#haiku' ); 
if( $haikuIndex !== FALSE ) {
   // "#haiku" exists
}

strstr example:

$haikuExists = strstr( $str, '#haiku' );

if( $haikuExists !== FALSE ) {
   // "#haiku" exists
}

You can also use strstr

if (strlen(strstr($str,'#haiku')) > 0) // "#haiku" exists

If you want a string tokenizer, then you probably want the strtok function

<?php
$string = "Summer is doubtful #haiku #poetry #babel";
$tok = strtok($string, " ");
while ($tok !== false) {
    if ($tok == "#haiku") {
        // #haiku exists
    }
    $tok = strtok(" ");
}
?>