note 76862 added to function.strripos
| From: | ElectroFox at osu1 dot php dot net | Date: | Thu, 02 Aug 2007 20:59:03 +0000 |
| Subject: | note 76862 added to function.strripos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129133@lists.php.net to get a copy of this message | ||
Sorry, I made that last post a bit prematurely. One more thing wrong with the simple php4 version
is that it breaks if the string is not found. It should actually look like this:
<?php
if (function_exists('strripos') == false) {
function strripos($haystack, $needle) {
$pos = strlen($haystack) - strpos(strrev($haystack), strrev($needle));
if ($pos == strlen($haystack)) { $pos = 0; }
return $pos;
}
}
?>
Note, we now check to see if the $needle was found, and if it isn't, we return 0.
----
Server IP: 208.69.120.35
Probable Submitter: 69.145.86.254
----
Manual Page -- http://www.php.net/manual/en/function.strripos.php
Edit -- https://master.php.net/note/edit/76862
Del: integrated -- https://master.php.net/note/delete/76862/integrated
Del: useless -- https://master.php.net/note/delete/76862/useless
Del: bad code -- https://master.php.net/note/delete/76862/bad+code
Del: spam -- https://master.php.net/note/delete/76862/spam
Del: non-english -- https://master.php.net/note/delete/76862/non-english
Del: in docs -- https://master.php.net/note/delete/76862/in+docs
Del: other reasons-- https://master.php.net/note/delete/76862
Reject -- https://master.php.net/note/reject/76862
Search -- https://master.php.net/manage/user-notes.php