note 111307 deleted from function.explode by salathe

From: Date: Mon, 21 Sep 2020 14:50:37 +0000
Subject: note 111307 deleted from function.explode by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215349@lists.php.net to get a copy of this message
Note Submitter: php at metehanarslan dot com ---- 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] => ) // ) ?>

« previous php.notes (#215349) next »