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

180 Views

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

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

 

Tags:-
PHP