note 75791 deleted from function.strstr by thiago
| From: | thiago@php.net | Date: | Tue, 28 Oct 2008 13:42:13 +0000 |
| Subject: | note 75791 deleted from function.strstr by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145864@lists.php.net to get a copy of this message | ||
Note Submitter: Eric
----
Example 1. stristr() example
<?php
$email = 'USER@EXAMPLE.com';
echo stristr($email, 'e');
// outputs ER@EXAMPLE.com
?>
Example 2. Testing if a string is found or not
<?php
$string = 'Hello World!';
if(stristr($string, 'earth') === FALSE) {
echo '"earth" not found in string';
}
// outputs: "earth" not found in string
?>
Example 3. Using a non "string" needle
<?php
$string = 'APPLE';
echo stristr($string, 97); // 97 = lowercase a
// outputs: APPLE
?>
I use this a lot at http://www.linksback.org