note 78499 added to function.strrpos

From: Date: Mon, 15 Oct 2007 12:41:05 +0000
Subject: note 78499 added to function.strrpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-131396@lists.php.net to get a copy of this message
Here is a simple function to find the position of the next occurrence of needle in haystack, but searching backwards (lastIndexOf type function): //search backwards for needle in haystack, and return its position function rstrpos ($haystack, $needle, $offset){ $size = strlen ($haystack); $pos = strpos (strrev($haystack), $needle, $size - $offset); if ($pos === false) return false; return $size - $pos; } Note: supports full strings as needle ---- Server IP: 194.8.30.16 Probable Submitter: 82.154.203.167 ---- Manual Page -- http://www.php.net/manual/en/function.strrpos.php Edit -- https://master.php.net/note/edit/78499 Del: integrated -- https://master.php.net/note/delete/78499/integrated Del: useless -- https://master.php.net/note/delete/78499/useless Del: bad code -- https://master.php.net/note/delete/78499/bad+code Del: spam -- https://master.php.net/note/delete/78499/spam Del: non-english -- https://master.php.net/note/delete/78499/non-english Del: in docs -- https://master.php.net/note/delete/78499/in+docs Del: other reasons-- https://master.php.net/note/delete/78499 Reject -- https://master.php.net/note/reject/78499 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131396) next »