note 69029 deleted from function.strpos by bjori

From: Date: Wed, 23 Aug 2006 07:37:28 +0000
Subject: note 69029 deleted from function.strpos by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116205@lists.php.net to get a copy of this message
Note Submitter: dorphalsig-NOSPAM- at -NOSPAM-gmail dot com ---- here is a strpos that will accept $needle as an array and will search $haystack for any of the $needles in the array. Please note it will return the position of the FIRST encounter of any of $needles. That is: if $haystack="Jan Feb Mar Apr" and $Needles=array("Jan","Feb","Mar","Apr"), the result will be 0. function strposarray($haystack,$needles,$offset=0) { $pos=false; $i=0; while($pos===false) { $pos=strpos($haytstack,$needles[$i],$offset); $i++; } return $pos }

« previous php.notes (#116205) next »