Monday 29 September 2014

strstr in PHP

PHP strstr() function is utilized to searches its first string argument to see if its second string argument is contained in it. Returns the substring of the first string that starts with the first instance of the second argument, if any is found – otherwise, it returns false. 

Syntax:

strstr(string,search)
string : Required. Specifies the input string.

search : Required.Specifies the string to search for.

Note : PHP strstr() function is binary-safe.

Note : PHP strstr() function is case-sensitive. For case-insensitive search, use PHP stristr() function.

Example:

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

0 comments:

Post a Comment