note 78577 added to function.strripos

From: Date: Thu, 18 Oct 2007 00:23:02 +0000
Subject: note 78577 added to function.strripos
Groups: php.notes 
Request: Send a blank email to php-notes+get-131478@lists.php.net to get a copy of this message
I think you shouldn't underestimate the length of $needle in the search of THE FIRST POSITION of it's last occurrence in the string. I improved the posted function, with added support for offset. I think this is an exact copy of the real function: <?php if(!function_exists("strripos")){ function strripos($haystack, $needle, $offset=0) { if($offset<0){ $temp_cut = strrev( substr( $haystack, 0, abs($offset) ) ); } else{ $temp_cut = strrev( substr( $haystack, $offset ) ); } $pos = strlen($haystack) - (strpos($temp_cut, strrev($needle)) + $offset + strlen($needle)); if ($pos == strlen($haystack)) { $pos = 0; } return $pos; }/* endfunction strripos*/ }/* endfunction exists strripos*/ ?> ---- Server IP: 69.147.83.197 Probable Submitter: 87.120.68.77 ---- Manual Page -- http://www.php.net/manual/en/function.strripos.php Edit -- https://master.php.net/note/edit/78577 Del: integrated -- https://master.php.net/note/delete/78577/integrated Del: useless -- https://master.php.net/note/delete/78577/useless Del: bad code -- https://master.php.net/note/delete/78577/bad+code Del: spam -- https://master.php.net/note/delete/78577/spam Del: non-english -- https://master.php.net/note/delete/78577/non-english Del: in docs -- https://master.php.net/note/delete/78577/in+docs Del: other reasons-- https://master.php.net/note/delete/78577 Reject -- https://master.php.net/note/reject/78577 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131478) next »