fork download
  1. <?php
  2.  
  3. $text = "red 1 green 3 blue";
  4. print_r(preg_split('~red|green|blue~', $text));
  5. print_r(preg_split('~red|green|blue~', $text, -1, PREG_SPLIT_NO_EMPTY));
Success #stdin #stdout 0.02s 24340KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 
    [1] =>  1 
    [2] =>  3 
    [3] => 
)
Array
(
    [0] =>  1 
    [1] =>  3 
)