note 68775 deleted from function.explode by bjori

From: Date: Mon, 25 Sep 2006 08:05:45 +0000
Subject: note 68775 deleted from function.explode by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117566@lists.php.net to get a copy of this message
Note Submitter: Rowan Lewis ---- I noticed that the ExplodeI functions listed below lack some of the features of Explode, so here you have it, an ExplodeI function that compatible with the PHP5.10 Explode function: <?php function ExplodeI($Seperator, $String, $Limit = Null) { if (!$Seperator) { return false; } $Count = 0; $CountNegative = 0; $Length = StrLen($Seperator); $Return = Array(); while (True) { $Count++; // Deal with positive limits: if ($Limit > 0 and $Count == $Limit) { break; } // Find our seperator: $Position = StrIPos($String, $Seperator); if ($Position === false) { break; } // Cut the old one out: $Return[] = SubStr($String, 0, $Position); $String = SubStr($String, $Position + $Length); } // Add the remainder: $Return[] = $String; // Deal with negative limits: if ($Limit < 0) { return Array_Slice($Return, 0, $Limit); } return $Return; } ?>

« previous php.notes (#117566) next »