note 26657 deleted from function.strstr by bjori
| From: | bjori@php.net | Date: | Thu, 27 Apr 2006 00:23:52 +0000 |
| Subject: | note 26657 deleted from function.strstr by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109804@lists.php.net to get a copy of this message | ||
Note Submitter: john :: beech :: at :: mkv25 :: dot :: net
----
function backstr($haystack, $needle) {
return substr($haystack, 0, strlen($haystack) - strlen(strstr($haystack,$needle)));
}
An extension of the above code, the function backstr will do the same as strstr, but returns the
string back from the needle instead of forward.
echo backstr("joanne@home.net", "@"); // Outputs 'Joanne'
Always try to make things easy for your self, and keep code uncluttered!