note 39613 added to function.strrpos

From: Date: Wed, 04 Feb 2004 17:17:21 +0000
Subject: note 39613 added to function.strrpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-64644@lists.php.net to get a copy of this message
//This function does what strrpos would if it handled multi-character strings: function getLastStr($hay, $need){ $getLastStr = 0; $pos = strpos($hay, $need); if (is_int ($pos)){ //this is to decide whether it is "false" or "0" while($pos) { $getLastStr = $getLastStr + $pos + strlen($need); $hay = substr ($hay , $pos + strlen($need)); $pos = strpos($hay, $need); } return $getLastStr - strlen($need); } else { return -1; //if $need wasn´t found it returns "-1" , because it could return "0" if it´s found on position "0". } } ---- Manual Page -- http://www.php.net/manual/en/function.strrpos.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39613 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39613&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39613&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64644) next »