note 60102 deleted from function.split by tularis

From: Date: Mon, 26 Dec 2005 23:08:37 +0000
Subject: note 60102 deleted from function.split by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-100756@lists.php.net to get a copy of this message
Note Submitter: shimon at schoolportal dot co dot il Reason: already in docs ---- <?php // ** // * splitslash() // * // * @since 25/12/05 21:26:00 // * @author shimon doodkin // * // * @param $string split by // * @param $string stlitted string // * @param $integer maximum number on array values to return // * @param $string escape character // * @return Array() // ** function splitslash($split,$str,$max=0,$esc='\\\\') { $o=explode($split,$str); $oc=count($o); $a=array(); for($i=0;$i<$oc;$i++) { $o2=explode($esc.$esc,$o[$i]); $o2c=count($o2); if(strlen($o2[$o2c-1])>1&&$o2[$o2c-1][strlen($o2[$o2c-1])-1]==$esc) { if($i+1<$oc) { $o2[$o2c-1]=substr($o2[$o2c-1],0,-1); $o[$i+1]=join($esc.$esc,$o2).$split.$o[$i+1]; } else { //echo "error"; if(count($a)-1>-1) $a[count($a)-1].=join($esc,$o2); else return array(join($esc,$o2)); } } else { $a[]=join($esc,$o2); } if($max>0&&count($a)==$max) { $i++; for(;$i<$oc;$i++) { $a[$max-1].=$split.str_replace($esc.$esc,$esc,$o[$i]); } break; } } return $a; } // example //$r=splitslash("NA","mooNAmooNAma\\\\ma\\NAfdsfasd"); //print_r($r); ?>

« previous php.notes (#100756) next »