The strchr() function is used to search for the first occurrence of a string inside another.
Note − This function is case-sensitive.
Syntax
strchr(str, search, before_search)
Parameters
str − The string to search
search − The string to search for
before_search − If TRUE, the function returns the part of the str before the first occurrence of the $search
Return
The strchr() function returns the rest of the string from the matching point. FALSE, if the string to search for is not found.
Example
The following is an example −
<?php echo strchr("Demo text!","text"); ?>
Output
text!
Example
The following is an example −
<?php $str= "This is demo text!"; $findStr = "demo" ; echo strchr($str, $findStr, true); ?>
Output
This is