note 92045 added to function.explode

From: Date: Tue, 07 Jul 2009 00:43:41 +0000
Subject: note 92045 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-157988@lists.php.net to get a copy of this message
You need function that skips delimeter check if needed? (There was one posted above, but as I tested, it didn't work correctly as it should) Thusand times of: explodeSkipNeeded():1.866 sec explode():0.04 sec (On PC, 1,5 Ghz AMD Sempron) <?php function explodeSkipNeeded($delimeter, $holder, $string){//neG for($i = 0; $i < strlen($string); $i++){ $char = $string[$i]; if($char == $holder && $string[$i-1] != '\\'){ $inHolder = (!$inHolder) ? true : false; }else{ if ($char == $delimeter && !$inHolder){ $ret[] = $str; unset($str); }else{ $str .= $char; } } } $ret[] = stripslashes($str); return $ret; } print_r($base->explodeSkipNeeded(';', '"', 'multiselect;"style=\"background=url(\'img.jpg\'); color:red;\""')); #Output would be: Array ( [0] => multiselect [1] => style="background=url('img.jpg'); color:red;" ) ?> ---- Server IP: 212.47.220.13 Probable Submitter: 84.50.139.251 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- https://master.php.net/note/edit/92045 Del: integrated -- https://master.php.net/note/delete/92045/integrated Del: useless -- https://master.php.net/note/delete/92045/useless Del: bad code -- https://master.php.net/note/delete/92045/bad+code Del: spam -- https://master.php.net/note/delete/92045/spam Del: non-english -- https://master.php.net/note/delete/92045/non-english Del: in docs -- https://master.php.net/note/delete/92045/in+docs Del: other reasons-- https://master.php.net/note/delete/92045 Reject -- https://master.php.net/note/reject/92045 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157988) next »