fork(2) download
  1. <?php
  2.  
  3. $str = '[date|Y-m-d] [date|Y-m-d|today]';
  4. preg_match_all('/\[([^][]+)]/', $str, $matches);
  5. $res = [];
  6. foreach ($matches[1] as $m) {
  7. array_push($res,explode("|", $m));
  8. }
  9. print_r($res);
  10.  
Success #stdin #stdout 0.02s 23780KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => date
            [1] => Y-m-d
        )

    [1] => Array
        (
            [0] => date
            [1] => Y-m-d
            [2] => today
        )

)