note 58959 deleted from function.explode by bjori

From: Date: Mon, 25 Sep 2006 08:07:00 +0000
Subject: note 58959 deleted from function.explode by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117572@lists.php.net to get a copy of this message
Note Submitter: kroczu at interia dot pl ---- case-insensitive version of explode() <? function explodei($separator, &$txt){ // working in PHP 5 (fast) /////////////////////////// if(function_exists("str_ireplace")){ $separator_l=strtolower($separator); return explode($separator_l, str_ireplace($separator, $separator_l, $txt)); } // PHP < 5 (slow) /////////////////////////////////// $txt_l=strlen($txt); $separator_l=strlen($separator); $separator=strtolower($separator); $j=0; $row=0; $stop=false; $start=0; for($i=0; $i<$txt_l; $i++){ if($txt[$i]==$separator[$j]){ if($stop===false) $stop=$i; $j++; if($j==$separator_l){ $tab[$row]=substr($txt, $start, $stop-$start); $row++; $i=$start=$stop+$separator_l; $stop=false; $j=0; } } elseif($stop!==false){ $i=$stop+1; $stop=false; $j=0; } } $tab[$row]=substr($txt, $start); return $tab; } ?>

« previous php.notes (#117572) next »