Friday 15 November 2013

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

strstr -- Find first occurrence of a string and get the string from that character

strstr() example

<?php
$mail = 'pass@examplem.com';
$domain = strstr($mail, '@');
echo $domain; // prints @examplem.com
?>

stristr -- Case-insensitive strstr()

stristr() example

<?php
$email = 'USER@EXAMPLE.com';
echo stristr($email, 'e');
// outputs ER@EXAMPLE.

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More