PHP Programing language

strchr() Function in PHP
Previous Home Next
adplus-dvertising

strchr()

The strchr() function searches for the first occurrence of a string inside another string.

Syntax:
strchr(string,search,before_search);

In above syntax, "string" specifies the string to search, "search" specifies the string to search for. If this parameter is a number, it will search for the character matching the ASCII value of the number and "before_search" is a boolean value whose default is "false". If set to "true", it returns the part of the string before the first occurrence of the search parameter.

Example:

<?php
echo strchr("Hello world! <br/>",101);
echo strchr("Hello world!","world");
?>

Output:

ello world! 
world!

Previous Home Next