3v4l.org

run code in 300+ PHP versions simultaneously
<?php $routes = [ 'primary' => [ 'pattern' => '#/(?P<resource>[^/\\\\.,;?\n]+)/foobar#', 'default' => [ 'action' => 'standard', ], ], 'secundary' => [ 'pattern' => '#^/(?P<id>[0-9]+)$#', 'default' => [ 'resource' => 'catalog', 'action' => 'view', ] ], 'fallback' => [ 'pattern' => '#^$#', 'default' => [ 'resource' => 'main', 'action' => 'landing', ], ], ]; $url = '/foobar/12345'; $current = null; foreach ($routes as $name => $route) { $matches = []; if ( preg_match( $route['pattern'], $url, $matches ) ) { $current = $name; break; } } var_dump( $name, $matches );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
Branch analysis from position: 17
filename:       /in/Fa1s8
function name:  (null)
number of ops:  23
compiled vars:  !0 = $routes, !1 = $url, !2 = $current, !3 = $route, !4 = $name, !5 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   27     1        ASSIGN                                                   !1, '%2Ffoobar%2F12345'
   28     2        ASSIGN                                                   !2, null
   30     3      > FE_RESET_R                                       $9      !0, ->17
          4    > > FE_FETCH_R                                       ~10     $9, !3, ->17
          5    >   ASSIGN                                                   !4, ~10
   31     6        ASSIGN                                                   !5, <array>
   32     7        INIT_FCALL                                               'preg_match'
          8        FETCH_DIM_R                                      ~13     !3, 'pattern'
          9        SEND_VAL                                                 ~13
         10        SEND_VAR                                                 !1
         11        SEND_REF                                                 !5
         12        DO_ICALL                                         $14     
         13      > JMPZ                                                     $14, ->16
   33    14    >   ASSIGN                                                   !2, !4
   34    15      > JMP                                                      ->17
   30    16    > > JMP                                                      ->4
         17    >   FE_FREE                                                  $9
   39    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !4
         20        SEND_VAR                                                 !5
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.63 ms | 1387 KiB | 17 Q