3v4l.org

run code in 300+ PHP versions simultaneously
<?php $urls = [ 'list/jhon/july-8-2023/', 'list/jhon-july-8-2023/', 'list/jhon/july-8-2023', 'list/jhon-july-8-2023', 'list/8-2023-jhon-july/', 'list/8-2023-jhon-july-some-thing-more-than-desired/', ]; $patterns = [ 'simple' => '^list/(\w+)-(.*)/$', 'explicit' => '^list/([a-z]+)-([a-z]+-\d{1,2}-\d{4})/?$', 'optional' => '^list/(\w+)[\-/](\w+-\d{1,2}-\d{4})/?$' ]; foreach($patterns as $type => $p) { echo $type . ' pattern ' . $p . PHP_EOL; foreach($urls as $url) { preg_match("#$p#", $url, $matches); if ($matches) { echo $url . ': ' . var_export($matches, true) . PHP_EOL; } } echo PHP_EOL . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 32
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 29
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 29
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 29
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/3qHUa
function name:  (null)
number of ops:  34
compiled vars:  !0 = $urls, !1 = $patterns, !2 = $p, !3 = $type, !4 = $url, !5 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   18     2      > FE_RESET_R                                       $8      !1, ->32
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->32
          4    >   ASSIGN                                                   !3, ~9
   19     5        CONCAT                                           ~11     !3, '+pattern+'
          6        CONCAT                                           ~12     ~11, !2
          7        CONCAT                                           ~13     ~12, '%0A'
          8        ECHO                                                     ~13
   20     9      > FE_RESET_R                                       $14     !0, ->29
         10    > > FE_FETCH_R                                               $14, !4, ->29
   21    11    >   INIT_FCALL                                               'preg_match'
         12        ROPE_INIT                                     3  ~16     '%23'
         13        ROPE_ADD                                      1  ~16     ~16, !2
         14        ROPE_END                                      2  ~15     ~16, '%23'
         15        SEND_VAL                                                 ~15
         16        SEND_VAR                                                 !4
         17        SEND_REF                                                 !5
         18        DO_ICALL                                                 
   22    19      > JMPZ                                                     !5, ->28
   23    20    >   CONCAT                                           ~19     !4, '%3A+'
         21        INIT_FCALL                                               'var_export'
         22        SEND_VAR                                                 !5
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $20     
         25        CONCAT                                           ~21     ~19, $20
         26        CONCAT                                           ~22     ~21, '%0A'
         27        ECHO                                                     ~22
   20    28    > > JMP                                                      ->10
         29    >   FE_FREE                                                  $14
   26    30        ECHO                                                     '%0A%0A'
   18    31      > JMP                                                      ->3
         32    >   FE_FREE                                                  $8
   27    33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.47 ms | 1012 KiB | 15 Q