fork download
  1. <?php
  2.  
  3. $re = "/([a-z]*(?:\\[[^]]*\\]|\\([^()]*\\)),?)|(?<=,)/";
  4. $str = "\$msg,array('goo','gle'),000,\"face\",'book',['twi'=>'ter','link'=>'edin']";
  5. print_r(preg_split($re, $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY));
Success #stdin #stdout 0.02s 24144KB
stdin
Standard input is empty
stdout
Array
(
    [0] => $msg,
    [1] => array('goo','gle'),
    [2] => 000,
    [3] => "face",
    [4] => 'book',
    [5] => ['twi'=>'ter','link'=>'edin']
)