fork download
  1. <?php
  2.  
  3. $s = '1-2=3-4=5';
  4. $parts = preg_split('/([-=])/', $s, null, PREG_SPLIT_DELIM_CAPTURE);
  5. var_dump($parts);
  6.  
Success #stdin #stdout 0.02s 24144KB
stdin
Standard input is empty
stdout
array(9) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "-"
  [2]=>
  string(1) "2"
  [3]=>
  string(1) "="
  [4]=>
  string(1) "3"
  [5]=>
  string(1) "-"
  [6]=>
  string(1) "4"
  [7]=>
  string(1) "="
  [8]=>
  string(1) "5"
}