php man page for strstr

Query: strstr

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

STRSTR(3)								 1								 STRSTR(3)

strstr - Find the first occurrence of a string

SYNOPSIS
string strstr (string $haystack, mixed $needle, [bool $before_needle = false])
DESCRIPTION
Returns part of $haystack string starting from and including the first occurrence of $needle to the end of $haystack. Note This function is case-sensitive. For case-insensitive searches, use stristr(3). Note If you only want to determine if a particular $needle occurs within $haystack, use the faster and less memory intensive function strpos(3) instead.
PARAMETERS
o $haystack - The input string. o $needle - If $needle is not a string, it is converted to an integer and applied as the ordinal value of a character. o $before_needle - If TRUE, strstr(3) returns the part of the $haystack before the first occurrence of the $needle (excluding the needle).
RETURN VALUES
Returns the portion of string, or FALSE if $needle is not found.
CHANGELOG
+--------+-----------------------------------------------+ |Version | | | | | | | Description | | | | +--------+-----------------------------------------------+ | 5.3.0 | | | | | | | Added the optional parameter $before_needle. | | | | | 4.3.0 | | | | | | | strstr(3) was made binary safe. | | | | +--------+-----------------------------------------------+
EXAMPLES
Example #1 strstr(3) example <?php $email = 'name@example.com'; $domain = strstr($email, '@'); echo $domain; // prints @example.com $user = strstr($email, '@', true); // As of PHP 5.3.0 echo $user; // prints name ?>
SEE ALSO
stristr(3), strrchr(3), strpos(3), strpbrk(3), preg_match(3). PHP Documentation Group STRSTR(3)
Related Man Pages
strstr(3) - mojave
strpos(3) - php
in_array(3) - php
stripos(3) - php
strripos(3) - php
Similar Topics in the Unix Linux Community
Output all commands to logfiles ???
can't email my own domain
Identify unknown LAN server from IP or MAC address
Counting occurrence of all words in a file
Trim after nth occurrence with loop