What is difference between strstr() and stristr() function ?

Last updated 5 years ago | 2306 views 75     5

Tags:- PHP

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 = 'raghav@yaHoo.com';

$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 = 'raghav@yaHoo.com';

$str = stristr($email, 'H');

echo $str; 

?>

// Output will be hov@yaHoo.com