note 109282 added to function.strrpos
| From: | arlaudpierre | Date: | Mon, 02 Jul 2012 13:51:30 +0000 |
| Subject: | note 109282 added to function.strrpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189004@lists.php.net to get a copy of this message | ||
This seems to behave like the exact equivalent to the PHP 5 offset parameter for a PHP 4 version.
<?php
function strrpos_handmade($haystack, $needle, $offset = 0){
if($offset === 0) return strrpos($haystack, $needle);
$length = strlen($haystack);
$size = strlen($needle);
if($offset < 0) {
$virtual_cut = $length+$offset;
$haystack = substr($haystack, 0, $virtual_cut+$size);
$ret = strrpos($haystack, $needle);
return $ret > $virtual_cut ? false : $ret;
} else {
$haystack = substr($haystack, $offset);
$ret = strrpos($haystack, $needle);
return $ret === false ? $ret : $ret+$offset;
}
}
?>
----
Server IP: 195.26.5.11
Probable Submitter: 78.141.136.248
----
Manual Page -- http://www.php.net/manual/en/function.strrpos.php
Edit -- https://master.php.net/note/edit/109282
Del: integrated -- https://master.php.net/note/delete/109282/integrated
Del: useless -- https://master.php.net/note/delete/109282/useless
Del: bad code -- https://master.php.net/note/delete/109282/bad+code
Del: spam -- https://master.php.net/note/delete/109282/spam
Del: non-english -- https://master.php.net/note/delete/109282/non-english
Del: in docs -- https://master.php.net/note/delete/109282/in+docs
Del: other reasons-- https://master.php.net/note/delete/109282
Reject -- https://master.php.net/note/reject/109282
Search -- https://master.php.net/manage/user-notes.php