note 104007 modified in function.explode by danbrown
| From: | danbrown@php.net | Date: | Tue, 17 May 2011 14:11:13 +0000 |
| Subject: | note 104007 modified in function.explode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179791@lists.php.net to get a copy of this message | ||
Nifty multiple explode function:
<?php
function multipleExplode($delimiters = array(), $string = ''){
$mainDelim=$delimiters[count($delimiters)-1]; // dernier
array_pop($delimiters);
foreach($delimiters as $delimiter){
$string= str_replace($delimiter, $mainDelim, $string);
}
$result= explode($mainDelim, $string);
return $result;
}
?>
--was--
Nifty multiple explode function:
function multipleExplode($delimiters = array(), $string = ''){
$mainDelim=$delimiters[count($delimiters)-1]; // dernier
array_pop($delimiters);
foreach($delimiters as $delimiter){
$string= str_replace($delimiter, $mainDelim, $string);
}
$result= explode($mainDelim, $string);
return $result;
}
http://php.net/manual/en/function.explode.php