note 98457 deleted from function.explode by danbrown
| From: | danbrown@php.net | Date: | Wed, 16 Jun 2010 14:49:22 +0000 |
| Subject: | note 98457 deleted from function.explode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-170187@lists.php.net to get a copy of this message | ||
Note Submitter: Cerda
----
simplified version of jessebusman's code:
<?php
print_r(explodeX(Array(".","!","
","?",";"),"This.sentence?contains wrong;characters"));
function explodeX($delimiters, $string)
{
// choose a delimiter
$delimiter = $delimiters[0];
// replace all the delimiters with the chosen one ...
$string = str_replace($delimiters, $delimiter, $string);
// explode the string with unified delimiters ...
return explode($delimiter, $string);
}
?>