3v4l.org

run code in 300+ 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 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 4
Branch analysis from position: 42
Branch analysis from position: 4
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 4
Branch analysis from position: 42
Branch analysis from position: 4
filename:       /in/nMBZi
function name:  (null)
number of ops:  44
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    >   INIT_FCALL                                               'strpos'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 '%3F'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $10     
          9        ASSIGN                                                   !2, $10
   14    10        TYPE_CHECK                                    4          !2
         11      > JMPZ                                                     ~12, ->13
   15    12    > > JMP                                                      ->42
   17    13    >   INIT_FCALL                                               'array_values'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $13     
         16        COUNT                                            ~14     !1
         17        MOD                                              ~15     !3, ~14
         18        FETCH_DIM_R                                      ~16     $13, ~15
         19        ASSIGN                                                   !4, ~16
   18    20        INIT_FCALL                                               'is_numeric'
         21        SEND_VAR                                                 !4
         22        DO_ICALL                                         $18     
         23      > JMPZ                                                     $18, ->26
         24    >   QM_ASSIGN                                        ~19     !4
         25      > JMP                                                      ->29
         26    >   CONCAT                                           ~20     '%22', !4
         27        CONCAT                                           ~21     ~20, '%22'
         28        QM_ASSIGN                                        ~19     ~21
         29    >   ASSIGN                                                   !5, ~19
   19    30        INIT_FCALL                                               'substr_replace'
         31        SEND_VAR                                                 !0
         32        SEND_VAR                                                 !5
         33        SEND_VAR                                                 !2
         34        SEND_VAL                                                 1
         35        DO_ICALL                                         $23     
         36        ASSIGN                                                   !0, $23
   20    37        STRLEN                                           ~25     !5
         38        ASSIGN_OP                                     1          !2, ~25
   21    39        PRE_INC                                                  !3
   22    40        TYPE_CHECK                                  1018          !2
         41      > JMPNZ                                                    ~28, ->4
   24    42    >   ECHO                                                     !0
   25    43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.52 ms | 1445 KiB | 17 Q