note 108461 deleted from function.strrpos by danbrown

From: Date: Thu, 10 May 2012 16:57:18 +0000
Subject: note 108461 deleted from function.strrpos by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187618@lists.php.net to get a copy of this message
Note Submitter: kyle at shadowdev dot com ---- I was searching around the php.net site and couldn't find a function that combined the ability of strrpos and arrays, so using a prewritten function on the strpos page (http://us3.php.net/manual/en/function.strpos.php#105984), I've modified it to pick the last position of items in an array. Useful for getting the last position of items like ./?/!/)/]/etc <?php function strrpos_arr($haystack, $needle) { if(!is_array($needle)) $needle = array($needle); foreach($needle as $what) { if(($p = strrpos($haystack, $what))!==false) if ($p>$pos) $pos=$p; #get the last position of the items in the array } if ($pos) return $pos; else return false; } ?> Hopefully this helps someoneout

« previous php.notes (#187618) next »