note 54649 deleted from function.strpos by danbrown

From: Date: Sun, 17 May 2009 16:39:44 +0000
Subject: note 54649 deleted from function.strpos by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154874@lists.php.net to get a copy of this message
Note Submitter: vig0 ---- This function takes in a string and a delimiter. It then builds an array of the data in between the delimiter then returns the array. I needed this function for something that I'm doing and thought it was somewhat useful. function multiStrposArray($haystack, $needle){ $array = array(); $row = 0; $var = ""; for ($i=0; $i<strlen($haystack); $i++) { if (substr($haystack, $i, 1)==$needle) { $array[$row] = $var; $row++; $var = ""; } else { $var .= substr($haystack, $i, 1); } } if ($var) $array[$row] = $var; return $array; }

« previous php.notes (#154874) next »