note 32245 added to function.explode
| From: | stefan at NOSPAM dot elakpistol dot com | Date: | Wed, 21 May 2003 14:00:41 +0000 |
| Subject: | note 32245 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-48739@lists.php.net to get a copy of this message | ||
This function handles HTML-tags as "words", so each tag will become a single element in
the array that is returned.
function _explode($chr, $str) {
for ($i=0, $j=0; $i < strlen($str); $i++) {
if ($str{$i} == $chr) {
while ($str{$i+1} == $chr)
$i++;
$j++;
continue;
}
if ($str{$i} == "<") {
if (strlen($res[$j]) > 0)
$j++;
$pos = strpos($str, ">", $i);
$res[$j] .= substr($str, $i, $pos - $i+1);
$i += ($pos - $i);
$j++;
continue;
}
if ((($str{$i} == "\n") || ($str{$i} == "\r")) && (strlen($res[$j]) ==
0))
continue;
$res[$j] .= $str{$i};
}
return $res;
}
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32245
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32245&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32245&report=yes