Home >Backend Development >PHP Tutorial >strstr() function in PHP
strstr() function is used to find the first occurrence of a string.
Note - This function is case-sensitive.
strstr(str,search,before)
str - The string to search for
search - The string to search for
before - A boolean value, default value is "false". If set to "true", returns the portion of the string preceding the first occurrence of the search parameter.
strstr() function returns the rest of the string, or false if the string is not found.
The following is an example -
Live Demo
<?php echo strstr("Brad Pitt!", "a"); ?>
ad Pitt!
The following is an example -
Live Demo
<?php echo strstr("Brad Pitt!", "a", true); ?>
Br
The above is the detailed content of strstr() function in PHP. For more information, please follow other related articles on the PHP Chinese website!