note 81909 added to function.explode
| From: | ben dot 1plus1 at gmail dot com | Date: | Wed, 19 Mar 2008 00:26:55 +0000 |
| Subject: | note 81909 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137190@lists.php.net to get a copy of this message | ||
I rewrote explode() so it'll ignore separators that come after a backslash.
<?php
function dexplode($sep,$str){// explode() except $sep's that follow "\" are ignored
$retarr=array();
$thisstr="";
$x=0;
$arrnum=0;
while($x<strlen($str)){
if($str{$x}=="\\"){
if($str{$x+1}=="\\"){
$thisstr.="\\";
$x+=2;
}elseif($str{$x+1}==$sep){
$thisstr.=$sep;
$x+=2;
}else{
$thisstr.="\\";
$x++;
}
}elseif($str{$x}==":"){
$retarr[$arrnum]=$thisstr;
$arrnum++;
$x++;
$thisstr="";
}else{
$thisstr.=$str{$x};
$x++;
}
}
$retarr[$arrnum]=$thisstr;
return $retarr;
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 24.26.212.77
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- https://master.php.net/note/edit/81909
Del: integrated -- https://master.php.net/note/delete/81909/integrated
Del: useless -- https://master.php.net/note/delete/81909/useless
Del: bad code -- https://master.php.net/note/delete/81909/bad+code
Del: spam -- https://master.php.net/note/delete/81909/spam
Del: non-english -- https://master.php.net/note/delete/81909/non-english
Del: in docs -- https://master.php.net/note/delete/81909/in+docs
Del: other reasons-- https://master.php.net/note/delete/81909
Reject -- https://master.php.net/note/reject/81909
Search -- https://master.php.net/manage/user-notes.php