fork download
  1. <?php
  2.  
  3. preg_match_all('#post/(\d+)#', 'post/123', $matches, PREG_SET_ORDER, 0);
  4. print_r($matches);
  5.  
  6. preg_match_all('#post/(?P<id>\d+)#', 'post/123', $matches, PREG_SET_ORDER, 0);
  7. print_r($matches);
Success #stdin #stdout 0.02s 24412KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => post/123
            [1] => 123
        )

)
Array
(
    [0] => Array
        (
            [0] => post/123
            [id] => 123
            [1] => 123
        )

)