Dark Launch

PHP split on multiple delimiters

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

PHP
<?php
$input = 'a,b|c;d';
$parts = preg_split('/(,|;|\|)/', $input);
var_dump($parts);
Bash
$ php split.php
array(4) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [2]=>
  string(1) "c"
  [3]=>
  string(1) "d"
}