Monday 29 September 2014

stristr in PHP

PHP stristr() function is used  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:

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

search : Required. Specifies the string to search for.

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

Example:

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

0 comments:

Post a Comment