note 68775 added to function.explode
| From: | RowanLewis at osu1 dot php dot net | Date: | Thu, 10 Aug 2006 10:36:55 +0000 |
| Subject: | note 68775 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115753@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 203.220.0.234
Probable Submitter: 58.105.45.237
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- https://master.php.net/note/edit/68775
Del: integrated -- https://master.php.net/note/delete/68775/integrated
Del: useless -- https://master.php.net/note/delete/68775/useless
Del: bad code -- https://master.php.net/note/delete/68775/bad+code
Del: spam -- https://master.php.net/note/delete/68775/spam
Del: non-english -- https://master.php.net/note/delete/68775/non-english
Del: in docs -- https://master.php.net/note/delete/68775/in+docs
Del: other reasons-- https://master.php.net/note/delete/68775
Reject -- https://master.php.net/note/reject/68775
Search -- https://master.php.net/manage/user-notes.php