note 92044 added to function.in-array
| From: | neG at osu1 dot php dot net | Date: | Tue, 07 Jul 2009 00:40:53 +0000 |
| Subject: | note 92044 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-157987@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.in-array.php
Edit -- https://master.php.net/note/edit/92044
Del: integrated -- https://master.php.net/note/delete/92044/integrated
Del: useless -- https://master.php.net/note/delete/92044/useless
Del: bad code -- https://master.php.net/note/delete/92044/bad+code
Del: spam -- https://master.php.net/note/delete/92044/spam
Del: non-english -- https://master.php.net/note/delete/92044/non-english
Del: in docs -- https://master.php.net/note/delete/92044/in+docs
Del: other reasons-- https://master.php.net/note/delete/92044
Reject -- https://master.php.net/note/reject/92044
Search -- https://master.php.net/manage/user-notes.php