3v4l.org

run code in 300+ PHP versions simultaneously
<?php $uri = 'administrator/clients/client/11'; // function input $routes = array( 'administrator/clients' => 'administrator/clients', 'administrator/client/(:num)' => 'administrator/clients/client/$1', ); foreach ($routes as $route => $controller) { $key = preg_replace('#[$][0-9]+#', '([^/]+)', $controller); // Converter alle $1, $2 osv til "hvad som helts") if (preg_match('#^' . $key . '$#', $uri, $match)) { $route; // $uri skal altså ligne "administrator/client/11" } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/oKOc9
function name:  (null)
number of ops:  22
compiled vars:  !0 = $uri, !1 = $routes, !2 = $controller, !3 = $route, !4 = $key, !5 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'administrator%2Fclients%2Fclient%2F11'
    4     1        ASSIGN                                                   !1, <array>
    9     2      > FE_RESET_R                                       $8      !1, ->20
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->20
          4    >   ASSIGN                                                   !3, ~9
   10     5        INIT_FCALL                                               'preg_replace'
          6        SEND_VAL                                                 '%23%5B%24%5D%5B0-9%5D%2B%23'
          7        SEND_VAL                                                 '%28%5B%5E%2F%5D%2B%29'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $11     
         10        ASSIGN                                                   !4, $11
   13    11        INIT_FCALL                                               'preg_match'
         12        CONCAT                                           ~13     '%23%5E', !4
         13        CONCAT                                           ~14     ~13, '%24%23'
         14        SEND_VAL                                                 ~14
         15        SEND_VAR                                                 !0
         16        SEND_REF                                                 !5
         17        DO_ICALL                                         $15     
         18      > JMPZ                                                     $15, ->19
    9    19    > > JMP                                                      ->3
         20    >   FE_FREE                                                  $8
   19    21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.06 ms | 1387 KiB | 17 Q