3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = 'UPDATE `list` set `item`=?,`type`=? WHERE (`id` = ?);'; $data = array( 'item' => '1', 'type' => 'Are you ok?' ); $pos = 0; $index = 0; do { $pos = strpos($str, '?', $pos); if ($pos === false) { break; } $binding = array_values($data)[$index%count($data)]; $replacement = is_numeric($binding) ? $binding : '"' . $binding . '"'; $str = substr_replace($str, $replacement, $pos, 1); $pos += strlen($replacement); $index++; } while ($pos !== false); echo $str;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 4
Branch analysis from position: 37
Branch analysis from position: 4
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 4
Branch analysis from position: 37
Branch analysis from position: 4
filename:       /in/nMBZi
function name:  (null)
number of ops:  39
compiled vars:  !0 = $str, !1 = $data, !2 = $pos, !3 = $index, !4 = $binding, !5 = $replacement
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'UPDATE+%60list%60+set+%60item%60%3D%3F%2C%60type%60%3D%3F+WHERE++%28%60id%60+%3D+%3F%29%3B'
    5     1        ASSIGN                                                       !1, <array>
   10     2        ASSIGN                                                       !2, 0
   11     3        ASSIGN                                                       !3, 0
   13     4    >   FRAMELESS_ICALL_3                strpos              ~10     !0, '%3F'
          5        OP_DATA                                                      !2
          6        ASSIGN                                                       !2, ~10
   14     7        TYPE_CHECK                                        4          !2
          8      > JMPZ                                                         ~12, ->10
   15     9    > > JMP                                                          ->37
   17    10    >   INIT_FCALL                                                   'array_values'
         11        SEND_VAR                                                     !1
         12        DO_ICALL                                             $13     
         13        COUNT                                                ~14     !1
         14        MOD                                                  ~15     !3, ~14
         15        FETCH_DIM_R                                          ~16     $13, ~15
         16        ASSIGN                                                       !4, ~16
   18    17        FRAMELESS_ICALL_1                is_numeric          ~18     !4
         18      > JMPZ                                                         ~18, ->21
         19    >   QM_ASSIGN                                            ~19     !4
         20      > JMP                                                          ->24
         21    >   CONCAT                                               ~20     '%22', !4
         22        CONCAT                                               ~21     ~20, '%22'
         23        QM_ASSIGN                                            ~19     ~21
         24    >   ASSIGN                                                       !5, ~19
   19    25        INIT_FCALL                                                   'substr_replace'
         26        SEND_VAR                                                     !0
         27        SEND_VAR                                                     !5
         28        SEND_VAR                                                     !2
         29        SEND_VAL                                                     1
         30        DO_ICALL                                             $23     
         31        ASSIGN                                                       !0, $23
   20    32        STRLEN                                               ~25     !5
         33        ASSIGN_OP                                         1          !2, ~25
   21    34        PRE_INC                                                      !3
   22    35        TYPE_CHECK                                      1018          !2
         36      > JMPNZ                                                        ~28, ->4
   24    37    >   ECHO                                                         !0
   25    38      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.03 ms | 1484 KiB | 15 Q