3v4l.org

run code in 300+ PHP versions simultaneously
<?php $Models = [ 'users' => 'm_users', 'products' => 'm_products', 'customers' => 'm_customers']; $string = "SELECT users as Name,`users`.`family` AS Family, products.id AS PID, `customers`.`id` AD CID FROM users INNER JOIN customers INNER JOIN products WHERE customers.customers = 1 and users.users = 2 and `products`.`id` = 1 and products.name = 'me' ORDER BY customers.id DESC"; $string_1 = "SELECT users FROM users"; foreach ($Models as $alias => $table) { $string = preg_replace("/(\s|,)`?{$alias}`?/", "$1`{$table}`", $string); } echo $string;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/Rq8mb
function name:  (null)
number of ops:  22
compiled vars:  !0 = $Models, !1 = $string, !2 = $string_1, !3 = $table, !4 = $alias
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, 'SELECT+users+as+Name%2C%60users%60.%60family%60+AS+Family%2C+products.id+AS+PID%2C+%60customers%60.%60id%60+AD+CID+FROM+users+INNER+JOIN+customers+INNER+JOIN+products+WHERE+customers.customers+%3D+1+and+users.users+%3D+2+and+%60products%60.%60id%60+%3D+1+and+products.name+%3D+%27me%27+ORDER+BY+customers.id+DESC'
    9     2        ASSIGN                                                   !2, 'SELECT+users+FROM+users'
   10     3      > FE_RESET_R                                       $8      !0, ->19
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->19
          5    >   ASSIGN                                                   !4, ~9
   11     6        INIT_FCALL                                               'preg_replace'
          7        ROPE_INIT                                     3  ~12     '%2F%28%5Cs%7C%2C%29%60%3F'
          8        ROPE_ADD                                      1  ~12     ~12, !4
          9        ROPE_END                                      2  ~11     ~12, '%60%3F%2F'
         10        SEND_VAL                                                 ~11
         11        ROPE_INIT                                     3  ~15     '%241%60'
         12        ROPE_ADD                                      1  ~15     ~15, !3
         13        ROPE_END                                      2  ~14     ~15, '%60'
         14        SEND_VAL                                                 ~14
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $17     
         17        ASSIGN                                                   !1, $17
   10    18      > JMP                                                      ->4
         19    >   FE_FREE                                                  $8
   14    20        ECHO                                                     !1
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.33 ms | 1010 KiB | 14 Q