You are here : phpstringstrstr

strstr() - string

Returns part of haystack string starting from and including the first
   occurrence of needle to the end of
   haystack.
Parameters :
  • haystack - The input string.
  • needle - If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.
  • before_needle - If TRUE, strstr() returns the part of the haystack before the first occurrence of the needle (excluding the needle).

  • Syntax

    string strstr
        ( string $haystack
       , mixed $needle
       [, bool $before_needle = false
      ] )


    Example

    <?php$email  = 'name@example.com';$domain = strstr($email, '@');echo $domain; // prints @example.com$user = strstr($email, '@', true); // As of PHP 5.3.0echo $user; // prints name?>


    Output / Return Value


    Limitations


    Alternatives / See Also


    Reference