3v4l.org

run code in 300+ PHP versions simultaneously
<?php $updates = [ [ "service" => "k", "price" => "85.0", "id" => "442" ], [ "service" => "τεσ", "price" => "66.0", "price_show" => "0", "id" => "463" ] ]; $allowed = array_flip([ 'service', 'price', 'price_show', 'id' ]); foreach ($updates as $update) { $update = array_intersect_key($update, $allowed); $id = array_pop($update); $set = []; foreach ($update as $field => $value) { $set[] = "`{$field}`=:{$value}"; } $update = "UPDATE some_table SET " . implode(', ', $set). " WHERE serviceID=".$id; echo $update, "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 39
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 39
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 27
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/94P9g
function name:  (null)
number of ops:  41
compiled vars:  !0 = $updates, !1 = $allowed, !2 = $update, !3 = $id, !4 = $set, !5 = $value, !6 = $field
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'array_flip'
   21     2        SEND_VAL                                                 <array>
   20     3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
   27     5      > FE_RESET_R                                       $10     !0, ->39
          6    > > FE_FETCH_R                                               $10, !2, ->39
   28     7    >   INIT_FCALL                                               'array_intersect_key'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $11     
         11        ASSIGN                                                   !2, $11
   29    12        INIT_FCALL                                               'array_pop'
         13        SEND_REF                                                 !2
         14        DO_ICALL                                         $13     
         15        ASSIGN                                                   !3, $13
   30    16        ASSIGN                                                   !4, <array>
   31    17      > FE_RESET_R                                       $16     !2, ->27
         18    > > FE_FETCH_R                                       ~17     $16, !5, ->27
         19    >   ASSIGN                                                   !6, ~17
   32    20        ROPE_INIT                                     4  ~21     '%60'
         21        ROPE_ADD                                      1  ~21     ~21, !6
         22        ROPE_ADD                                      2  ~21     ~21, '%60%3D%3A'
         23        ROPE_END                                      3  ~20     ~21, !5
         24        ASSIGN_DIM                                               !4
         25        OP_DATA                                                  ~20
   31    26      > JMP                                                      ->18
         27    >   FE_FREE                                                  $16
   35    28        INIT_FCALL                                               'implode'
         29        SEND_VAL                                                 '%2C+'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                         $23     
         32        CONCAT                                           ~24     'UPDATE+some_table+SET+', $23
         33        CONCAT                                           ~25     ~24, '+WHERE+serviceID%3D'
         34        CONCAT                                           ~26     ~25, !3
         35        ASSIGN                                                   !2, ~26
   37    36        ECHO                                                     !2
         37        ECHO                                                     '%0A'
   27    38      > JMP                                                      ->6
         39    >   FE_FREE                                                  $10
   38    40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.67 ms | 1008 KiB | 17 Q