3v4l.org

run code in 500+ PHP versions simultaneously
<?php $rego_columns = [ "make", "model", "year", "rego", ]; $record = ['make' => 'A', 'model' => 'B', 'year' => 'C', 'rego' => 'D']; $tableValues = array_map(function($r) use ($record) { return $record[$r]; }, $rego_columns); $placeholders = implode(',', array_fill(0, count($tableValues), '?')); $tableColumns = '`' . implode('`,`', $rego_columns) . '`'; $query = 'INSERT INTO table_name (' . $tableColumns . ') VALUES(' . $placeholders . ')'; echo $query;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kcl4m
function name:  (null)
number of ops:  28
compiled vars:  !0 = $rego_columns, !1 = $record, !2 = $tableValues, !3 = $placeholders, !4 = $tableColumns, !5 = $query
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   10     1        ASSIGN                                                       !1, <array>
   12     2        INIT_FCALL                                                   'array_map'
          3        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
          4        BIND_LEXICAL                                                 ~8, !1
   14     5        SEND_VAL                                                     ~8
          6        SEND_VAR                                                     !0
   12     7        DO_ICALL                                             $9      
          8        ASSIGN                                                       !2, $9
   15     9        INIT_FCALL                                                   'array_fill'
         10        SEND_VAL                                                     0
         11        COUNT                                                ~11     !2
         12        SEND_VAL                                                     ~11
         13        SEND_VAL                                                     '%3F'
         14        DO_ICALL                                             $12     
         15        FRAMELESS_ICALL_2                implode             ~13     '%2C', $12
         16        ASSIGN                                                       !3, ~13
   16    17        FRAMELESS_ICALL_2                implode             ~15     '%60%2C%60', !0
         18        CONCAT                                               ~16     '%60', ~15
         19        CONCAT                                               ~17     ~16, '%60'
         20        ASSIGN                                                       !4, ~17
   18    21        CONCAT                                               ~19     'INSERT+INTO+table_name+%28', !4
         22        CONCAT                                               ~20     ~19, '%29+VALUES%28'
         23        CONCAT                                               ~21     ~20, !3
         24        CONCAT                                               ~22     ~21, '%29'
         25        ASSIGN                                                       !5, ~22
   21    26        ECHO                                                         !5
   22    27      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kcl4m
function name:  {closure:/in/kcl4m:12}
number of ops:  5
compiled vars:  !0 = $r, !1 = $record
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   13     2        FETCH_DIM_R                                          ~2      !1, !0
          3      > RETURN                                                       ~2
   14     4*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.59 ms | 2082 KiB | 15 Q