fork(1) download
  1. <?php
  2.  
  3. $str = 'id=22 tmpl=default';
  4.  
  5. $result = [];
  6. $rexp = '/([\w]+)=([^\s]+)/u';
  7.  
  8. $status = preg_match_all($rexp, $str, $result, PREG_SET_ORDER);
  9.  
  10. if ($status !== FALSE)
  11. {
  12. echo "Found $status matches:" . PHP_EOL;
  13. print_r($result);
  14. }
  15. else
  16. {
  17. echo "Error in test";
  18. }
Success #stdin #stdout 0.02s 24804KB
stdin
Standard input is empty
stdout
Found 2 matches:
Array
(
    [0] => Array
        (
            [0] => id=22
            [1] => id
            [2] => 22
        )

    [1] => Array
        (
            [0] => tmpl=default
            [1] => tmpl
            [2] => default
        )

)