Home » PHP strchr() function

PHP strchr() function

by Online Tutorials Library

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:

Parameter Description Required/Optional
String Specify the string to search. Required
Search Specify the string to search. If parameter is number then return ASCII value. required
before_search It 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 parameter Optional

Example 1

Output:

PHP  

Example 2

Output:

point!  

Example 3

Output:

Hello  

References:

http://php.net/manual/en/function.strchr.php

Next TopicPHP String

You may also like