PHP string strchr() Function

The string strchr() function is predefined function of PHP. It is the alias of strstr() function or can used to search for the first occurrence of a given string.

Note: This function is case sensitive and binary-safe.

Syntax:

ParameterDescriptionRequired/Optional
StringSpecify the string to search.Required
SearchSpecify the string to search. If parameter is number then return ASCII value.required
before_searchIt is false when default value is boolean. If it is true then returns the pars of the string before the first occurrence of the search parameterOptional

Example 1

Output:

PHP

Example 2

Output:

point!

Example 3

Output:

Hello

References:

http://php.net/manual/en/function.strchr.php
Next TopicPHP String




Latest Courses