PHP strstr() Function

PHP strstr() Function

The strstr() function in PHP finds the first occurrence of a string. It returns part of the parameter haystack string starting from and including the first occurrence of needle to the end of the haystack parameter. This function is case-sensitive. 

Syntax

Parameter

 haystack(required)– This parameter signifies the string to be unescaped.

needle(required)- This parameter represents a string of one or more characters. If it is not a string, it is converted to an integer and applied as the ordinal value of a character.

before_needle(optional)- This parameter accepts Boolean value, and its default value is False. If set TRUE, it returns the part of the haystack before the first occurrence of the needle parameter.

Return

This function returns the portion of the string, or FALSE if the needle is not found.

Example 1

Output

Example 2

Output

Example 3

Output

Example 4

Output