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)) { // Okay. Den matcher på $controller (array value) // Nu skal vi så konvertere $uri til den $route, der tilhører $controller echo $route . " => " . $controller; // Det er en her 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 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/GVl5n
function name:  (null)
number of ops:  25
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, ->23
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->23
          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
   15    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, ->22
   19    19    >   CONCAT                                           ~16     !3, '+%3D%3E+'
         20        CONCAT                                           ~17     ~16, !2
         21        ECHO                                                     ~17
    9    22    > > JMP                                                      ->3
         23    >   FE_FREE                                                  $8
   23    24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.43 ms | 1396 KiB | 17 Q