note 67559 added to function.strrpos

From: Date: Thu, 08 Jun 2006 19:53:10 +0000
Subject: note 67559 added to function.strrpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-113899@lists.php.net to get a copy of this message
################################################### # # DESCRIPTION: # This function returns the last occurance of a string, # rather than the last occurance of a single character like # strrpos does. It also supports an offset from where to # start the searching in the haystack string. # # ARGS: # $haystack (required) -- the string to search upon # $needle (required) -- the string you are looking for # $offset (optional) -- the offset to start from # # RETURN VALS: # returns integer on success # returns false on failure to find the string at all # ################################################### function strrpos_string($haystack, $needle, $offset = 0) { if(trim($haystack) != "" && trim($needle) != "" && $offset <= strlen($haystack)) { $last_pos = $offset; $found = false; while(($curr_pos = strpos($haystack, $needle, $last_pos)) !== false) { $found = true; $last_pos = $curr_pos + 1; } if($found) { return $last_pos - 1; } else { return false; } } else { return false; } } ---- Server IP: 216.194.113.175 Probable Submitter: 209.63.134.99 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.strrpos.php Edit -- http://master.php.net/note/edit/67559 Del: integrated -- http://master.php.net/note/delete/67559/integrated Del: useless -- http://master.php.net/note/delete/67559/useless Del: bad code -- http://master.php.net/note/delete/67559/bad+code Del: spam -- http://master.php.net/note/delete/67559/spam Del: non-english -- http://master.php.net/note/delete/67559/non-english Del: in docs -- http://master.php.net/note/delete/67559/in+docs Del: other reasons-- http://master.php.net/note/delete/67559 Reject -- http://master.php.net/note/reject/67559 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#113899) next »