note 31506 added to function.strrpos
| From: | no_spammage_at_wwwcrm_dot_com at rack1 dot php dot net | Date: | Thu, 24 Apr 2003 13:07:27 +0000 |
| Subject: | note 31506 added to function.strrpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47026@lists.php.net to get a copy of this message | ||
This function does what strrpos would if it handled multi-character strings:
//function recurses until it finds last instance of $needle in $haystack
function getLastStr($haystack, $needle, $first_time=1){
$test=strstr($haystack, $needle);//is the needle there?
if ($test) return getLastStr($test, $needle, 0);//see if there is another one?
else if ($first_time) return false;//there is no occurence at all
else return $haystack;//that was the last occurence
}
--
http://www.php.net/manual/en/function.strrpos.php
http://master.php.net/manage/user-notes.php?action=edit+31506
http://master.php.net/manage/user-notes.php?action=delete+31506
http://master.php.net/manage/user-notes.php?action=reject+31506