Home >>PHP String Functions >PHP strchr() Function
PHP strchr() function is used to search for the first presence of a given input string inside another string. It returns the rest of the string from original String starting from the first occurrence of search String in the original String. It is binary-safe and case-sensitive.
Syntax:
strchr($string,$search,$before_search);
Parameter | Description |
---|---|
String | This is a required parameter. This parameter contains the string to search. |
Search | This is a required parameter. This parameter contains the string to search for. |
before_search | This is an optional parameter.This holds a boolean value which is by default "false". If it is "true", it returns the part of the string before the first occurrence of the search parameter. |
Here is an example of strchr() function in PHP:
<html> <body> <?php echo strchr("Hello Everyone. Welcome!","Everyone"); ?> </body> </html>
Here is an another example of strchr() function in PHP:
<html> <body> <?php echo strchr("Hello Everyone, I am Jerry..","Jerry",true); ?> </body> </html>