Showing posts with label PHP strchr. Show all posts
Showing posts with label PHP strchr. Show all posts

Monday, 29 September 2014

strchr in PHP

 PHP strchr() function is utilized to find the first occurrence of a string inside another string (main string).
If char cannot be found, this function returns FALSE. 
It is an identical  to strstr() function.

Syntax:

strchr(string,search)
string : Required. Specifies the input string to search

search : Required. Specifies the string to search for.

Note : PHP strchr() function is binary-safe and case-sensitive. For case-insensitive search, use stristr() function.

Example:

<?php
echo strchr("Good Morning world!","Morning");
echo "<br /><strong> Example using ASCII code for search : </strong><br />";
echo strchr("Good Morning",111);
?>
Output will be:
Morning world!
Example using ASCII code for search :
ood Morning