3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( 'a' => 'va', 'b' => 'vb', 'c' => 'vc', ); $sql = "INSERT INTO Post(" . implode(', ', array_keys($arr)) . ") VALUES ('" . implode("', '", $arr) . "');"; echo "$sql\n"; $sql = "INSERT INTO Post("; $columns = $values = ''; foreach ($arr as $column => $value) { $columns .= "$column, "; $values .= $value ? "'$value', " : "NULL, "; } $sql .= trim($columns, ', ') . ") VALUES (" . trim($values, ', ') . ");"; echo "$sql\n"; $cols = count($arr); $keys = array_keys($arr); $sql = "INSERT INTO Post("; $columns = $values = ''; for ($c = 0; $c < $cols; $c++) { $key = $keys[$c]; $columns .= $key; $values .= $arr[$key] ? "'{$arr[$key]}'" : "NULL"; if ($c < $cols - 1) { $columns .= ', '; $values .= ', '; } } $sql .= "$columns) VALUES ($values);"; echo "$sql\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 38
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 38
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 65
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 76
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 77
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 83
Branch analysis from position: 81
2 jumps found. (Code = 44) Position 1 = 86, Position 2 = 65
Branch analysis from position: 86
Branch analysis from position: 65
Branch analysis from position: 83
Branch analysis from position: 76
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 83
Branch analysis from position: 81
Branch analysis from position: 83
Branch analysis from position: 38
filename:       /in/p35cT
function name:  (null)
number of ops:  95
compiled vars:  !0 = $arr, !1 = $sql, !2 = $columns, !3 = $values, !4 = $value, !5 = $column, !6 = $cols, !7 = $keys, !8 = $c, !9 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        INIT_FCALL                                               'implode'
          2        SEND_VAL                                                 '%2C+'
          3        INIT_FCALL                                               'array_keys'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $11     
          6        SEND_VAR                                                 $11
          7        DO_ICALL                                         $12     
          8        CONCAT                                           ~13     'INSERT+INTO+Post%28', $12
   11     9        CONCAT                                           ~14     ~13, '%29+VALUES+%28%27'
   12    10        INIT_FCALL                                               'implode'
         11        SEND_VAL                                                 '%27%2C+%27'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $15     
         14        CONCAT                                           ~16     ~14, $15
   13    15        CONCAT                                           ~17     ~16, '%27%29%3B'
    9    16        ASSIGN                                                   !1, ~17
   14    17        NOP                                                      
         18        FAST_CONCAT                                      ~19     !1, '%0A'
         19        ECHO                                                     ~19
   16    20        ASSIGN                                                   !1, 'INSERT+INTO+Post%28'
   17    21        ASSIGN                                           ~21     !3, ''
         22        ASSIGN                                                   !2, ~21
   18    23      > FE_RESET_R                                       $23     !0, ->38
         24    > > FE_FETCH_R                                       ~24     $23, !4, ->38
         25    >   ASSIGN                                                   !5, ~24
   19    26        NOP                                                      
         27        FAST_CONCAT                                      ~26     !5, '%2C+'
         28        ASSIGN_OP                                     8          !2, ~26
   20    29      > JMPZ                                                     !4, ->35
         30    >   ROPE_INIT                                     3  ~29     '%27'
         31        ROPE_ADD                                      1  ~29     ~29, !4
         32        ROPE_END                                      2  ~28     ~29, '%27%2C+'
         33        QM_ASSIGN                                        ~31     ~28
         34      > JMP                                                      ->36
         35    >   QM_ASSIGN                                        ~31     'NULL%2C+'
         36    >   ASSIGN_OP                                     8          !3, ~31
   18    37      > JMP                                                      ->24
         38    >   FE_FREE                                                  $23
   22    39        INIT_FCALL                                               'trim'
         40        SEND_VAR                                                 !2
         41        SEND_VAL                                                 '%2C+'
         42        DO_ICALL                                         $33     
         43        CONCAT                                           ~34     $33, '%29+VALUES+%28'
         44        INIT_FCALL                                               'trim'
         45        SEND_VAR                                                 !3
         46        SEND_VAL                                                 '%2C+'
         47        DO_ICALL                                         $35     
         48        CONCAT                                           ~36     ~34, $35
         49        CONCAT                                           ~37     ~36, '%29%3B'
         50        ASSIGN_OP                                     8          !1, ~37
   23    51        NOP                                                      
         52        FAST_CONCAT                                      ~39     !1, '%0A'
         53        ECHO                                                     ~39
   25    54        COUNT                                            ~40     !0
         55        ASSIGN                                                   !6, ~40
   26    56        INIT_FCALL                                               'array_keys'
         57        SEND_VAR                                                 !0
         58        DO_ICALL                                         $42     
         59        ASSIGN                                                   !7, $42
   27    60        ASSIGN                                                   !1, 'INSERT+INTO+Post%28'
   28    61        ASSIGN                                           ~45     !3, ''
         62        ASSIGN                                                   !2, ~45
   29    63        ASSIGN                                                   !8, 0
         64      > JMP                                                      ->84
   30    65    >   FETCH_DIM_R                                      ~48     !7, !8
         66        ASSIGN                                                   !9, ~48
   31    67        ASSIGN_OP                                     8          !2, !9
   32    68        FETCH_DIM_R                                      ~51     !0, !9
         69      > JMPZ                                                     ~51, ->76
         70    >   ROPE_INIT                                     3  ~54     '%27'
         71        FETCH_DIM_R                                      ~52     !0, !9
         72        ROPE_ADD                                      1  ~54     ~54, ~52
         73        ROPE_END                                      2  ~53     ~54, '%27'
         74        QM_ASSIGN                                        ~56     ~53
         75      > JMP                                                      ->77
         76    >   QM_ASSIGN                                        ~56     'NULL'
         77    >   ASSIGN_OP                                     8          !3, ~56
   33    78        SUB                                              ~58     !6, 1
         79        IS_SMALLER                                               !8, ~58
         80      > JMPZ                                                     ~59, ->83
   34    81    >   ASSIGN_OP                                     8          !2, '%2C+'
   35    82        ASSIGN_OP                                     8          !3, '%2C+'
   29    83    >   PRE_INC                                                  !8
         84    >   IS_SMALLER                                               !8, !6
         85      > JMPNZ                                                    ~63, ->65
   38    86    >   ROPE_INIT                                     4  ~65     !2
         87        ROPE_ADD                                      1  ~65     ~65, '%29+VALUES+%28'
         88        ROPE_ADD                                      2  ~65     ~65, !3
         89        ROPE_END                                      3  ~64     ~65, '%29%3B'
         90        ASSIGN_OP                                     8          !1, ~64
   39    91        NOP                                                      
         92        FAST_CONCAT                                      ~68     !1, '%0A'
         93        ECHO                                                     ~68
         94      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.21 ms | 1011 KiB | 16 Q