3v4l.org

run code in 300+ PHP versions simultaneously
<?php $original = [ '1439045372' => ['price' => 10], '1439131770' => ['price' => 11], '1439218169' => ['price' => 14], '1439304572' => ['price' => 15], '1439390970' => ['price' => 12], ]; $add_to_array = ["3","4","5"]; $n = 1; $result = []; foreach ($original as $key => $item){ $add = $item; if(in_array($n, $add_to_array)){ $add ['data'] = $n; } $result [$key]= $add; $n++; } var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 19
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 15
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/UcfXa
function name:  (null)
number of ops:  24
compiled vars:  !0 = $original, !1 = $add_to_array, !2 = $n, !3 = $result, !4 = $item, !5 = $key, !6 = $add
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   13     2        ASSIGN                                                   !2, 1
   14     3        ASSIGN                                                   !3, <array>
   15     4      > FE_RESET_R                                       $11     !0, ->19
          5    > > FE_FETCH_R                                       ~12     $11, !4, ->19
          6    >   ASSIGN                                                   !5, ~12
   16     7        ASSIGN                                                   !6, !4
   17     8        INIT_FCALL                                               'in_array'
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $15     
         12      > JMPZ                                                     $15, ->15
   18    13    >   ASSIGN_DIM                                               !6, 'data'
         14        OP_DATA                                                  !2
   20    15    >   ASSIGN_DIM                                               !3, !5
         16        OP_DATA                                                  !6
   21    17        PRE_INC                                                  !2
   15    18      > JMP                                                      ->5
         19    >   FE_FREE                                                  $11
   24    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.76 ms | 1395 KiB | 17 Q