
What is difference between strstr() and stristr() function ?
Last updated 5 years, 11 months ago | 3042 views 75 5

strstr() and stristr()
strstr() and stristr() both are use to find first occurence of a string, but the differences are strstr( ) is case sensitive where as stristr( ) is case insensitive.
strstr() – Find first occurrence of a string
strstr ($string, string)
<?php
$email = '[email protected]';
$str = strstr($email, 'H');
echo $str;
?>
// Output will be Hoo.com
stristr() – Find first occurrence of a string (Case-insensitive)
stristr ($string, string)
<?php
$email = '[email protected]';
$str = stristr($email, 'H');
echo $str;
?>
// Output will be [email protected]