PHP split on multiple delimiters

Use php to split a string using multiple characters like pipe, comma, semicolon, etc.

$input = 'a,b|c;d';
$parts = preg_split('/(,|;|\|)/', $input);
$ php split.php
array(4) {
string(1) "a"
string(1) "b"
string(1) "c"
string(1) "d"
If you liked this posting, please feel free to leave me a comment below.
View this page on GitHub.
Posted .


Leave a Reply