note 111307 added to function.explode
| From: | php at metehanarslan dot com | Date: | Mon, 04 Feb 2013 22:43:34 +0000 |
| Subject: | note 111307 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193527@lists.php.net to get a copy of this message | ||
Here is my approach to have exploded output with multiple delimiter.
<?php
//$delimiters has to be array
//$string has to be array
function multiexplode ($delimiters,$string) {
$ready = str_replace($delimiters, $delimiters[0], $string);
$launch = explode($delimiters[0], $ready);
return $launch;
}
$text = "here is a sample: this text, and this will be exploded. this also | this one too
:)";
$exploded = multiexplode(array(",",".","|",":"),$text);
print_r($exploded);
//And output will be like this:
// Array
// (
// [0] => here is a sample
// [1] => this text
// [2] => and this will be exploded
// [3] => this also
// [4] => this one too
// [5] => )
// )
?>
----
Server IP: 69.147.83.199
Probable Submitter: 46.196.235.156
----
Manual Page -- http://php.net/manual/en/function.explode.php
Edit -- https://master.php.net/note/edit/111307
Del: integrated -- https://master.php.net/note/delete/111307/integrated
Del: useless -- https://master.php.net/note/delete/111307/useless
Del: bad code -- https://master.php.net/note/delete/111307/bad+code
Del: spam -- https://master.php.net/note/delete/111307/spam
Del: non-english -- https://master.php.net/note/delete/111307/non-english
Del: in docs -- https://master.php.net/note/delete/111307/in+docs
Del: other reasons-- https://master.php.net/note/delete/111307
Reject -- https://master.php.net/note/reject/111307
Search -- https://master.php.net/manage/user-notes.php