3v4l.org

run code in 500+ PHP versions simultaneously
<?php $sizes = json_decode('{"0":{"size_id":5,"it":"50","us":"32"},"1":{"size_id":4,"it":"48","us":"30"}}', true); $percentages = json_decode('[{"5":"70"},{"4":"30"}]', true); $final = []; foreach($sizes AS $size) { $final[$size['size_id']] = $size; } foreach($percentages AS $percentage) { $final[key($percentage)]['percentage'] = current($percentage); } $final = array_values($final); print_r($final); echo json_encode($final);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 30
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 30
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 17
filename:       /in/LR8Tv
function name:  (null)
number of ops:  43
compiled vars:  !0 = $sizes, !1 = $percentages, !2 = $final, !3 = $size, !4 = $percentage
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'json_decode'
          1        SEND_VAL                                                     '%7B%220%22%3A%7B%22size_id%22%3A5%2C%22it%22%3A%2250%22%2C%22us%22%3A%2232%22%7D%2C%221%22%3A%7B%22size_id%22%3A4%2C%22it%22%3A%2248%22%2C%22us%22%3A%2230%22%7D%7D'
          2        SEND_VAL                                                     <true>
          3        DO_ICALL                                             $5      
          4        ASSIGN                                                       !0, $5
    4     5        INIT_FCALL                                                   'json_decode'
          6        SEND_VAL                                                     '%5B%7B%225%22%3A%2270%22%7D%2C%7B%224%22%3A%2230%22%7D%5D'
          7        SEND_VAL                                                     <true>
          8        DO_ICALL                                             $7      
          9        ASSIGN                                                       !1, $7
    6    10        ASSIGN                                                       !2, <array>
    8    11      > FE_RESET_R                                           $10     !0, ->17
         12    > > FE_FETCH_R                                                   $10, !3, ->17
    9    13    >   FETCH_DIM_R                                          ~11     !3, 'size_id'
         14        ASSIGN_DIM                                                   !2, ~11
         15        OP_DATA                                                      !3
    8    16      > JMP                                                          ->12
         17    >   FE_FREE                                                      $10
   12    18      > FE_RESET_R                                           $13     !1, ->30
         19    > > FE_FETCH_R                                                   $13, !4, ->30
   13    20    >   INIT_FCALL                                                   'key'
         21        SEND_VAR                                                     !4
         22        DO_ICALL                                             $14     
         23        INIT_FCALL                                                   'current'
         24        SEND_VAR                                                     !4
         25        DO_ICALL                                             $17     
         26        FETCH_DIM_W                                          $15     !2, $14
         27        ASSIGN_DIM                                                   $15, 'percentage'
         28        OP_DATA                                                      $17
   12    29      > JMP                                                          ->19
         30    >   FE_FREE                                                      $13
   16    31        INIT_FCALL                                                   'array_values'
         32        SEND_VAR                                                     !2
         33        DO_ICALL                                             $18     
         34        ASSIGN                                                       !2, $18
   18    35        INIT_FCALL                                                   'print_r'
         36        SEND_VAR                                                     !2
         37        DO_ICALL                                                     
   19    38        INIT_FCALL                                                   'json_encode'
         39        SEND_VAR                                                     !2
         40        DO_ICALL                                             $21     
         41        ECHO                                                         $21
         42      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
240.16 ms | 2693 KiB | 19 Q