Tuesday 10 June 2014

Difference between strstr and stristr in php.

Functions strstr() and stristr, these are used to find the first occurence of the string (case-sensitive) but stristr() is case insensitive.

strstr() - Find first occurrence of a string.

Syntax:
                   strstr ($string, string) 

Example:

<?php
                  $email = 'makersofweb@rAls.com';
                  $domain_name = strstr($email, 'A);
                 echo $domain_name;

?>

Output:

Als.com



stristr() - Find first occurrence of a string (Case-insensitive)




















stristr ($string, string) 

Example:

<?php
                     $email = 'makersofwb@rAls.com';
                     $domain_name = stristr($email, 'A');
                     echo $domain_name;
 ?>


Output-
              akersofwb@rAls.com

Posted by Amit Tiwari



No comments:

Post a Comment