3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arrA = array('a' => array('x' => 100), 'b' => array('x' => 200), 'c' => array('x' => 300)); // Array of Arrays $arrO = json_decode('[{"id": 1, "val": 10}, {"id": 2, "val": 20}, {"id": 3, "val": 30}]'); // Array of Objects foreach ($arrA as &$val) $val['x'] += 2; // this doesnt work (variable $val) unset($val); //foreach ($arrA as &$val2) $val2['x'] += 2; // this works (renamed reference variable) foreach ($arrO as $val) { foreach ($arrA as $item) error_log($item['x']); // last item in $arrA changed from Array to Object in array $arrO !!! break; // other itteration resulted in same error (last item changed) }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
2 jumps found. (Code = 126) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 24
Branch analysis from position: 24
Branch analysis from position: 10
filename:       /in/HiG2t
function name:  (null)
number of ops:  26
compiled vars:  !0 = $arrA, !1 = $arrO, !2 = $val, !3 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        INIT_FCALL                                                   'json_decode'
          2        SEND_VAL                                                     '%5B%7B%22id%22%3A+1%2C+%22val%22%3A+10%7D%2C+%7B%22id%22%3A+2%2C+%22val%22%3A+20%7D%2C+%7B%22id%22%3A+3%2C+%22val%22%3A+30%7D%5D'
          3        DO_ICALL                                             $5      
          4        ASSIGN                                                       !1, $5
    5     5      > FE_RESET_RW                                          $7      !0, ->10
          6    > > FE_FETCH_RW                                                  $7, !2, ->10
          7    >   ASSIGN_DIM_OP                    +=               1          !2, 'x'
          8        OP_DATA                                                      2
          9      > JMP                                                          ->6
         10    >   FE_FREE                                                      $7
    6    11        UNSET_CV                                                     !2
    8    12      > FE_RESET_R                                           $9      !1, ->24
         13    > > FE_FETCH_R                                                   $9, !2, ->24
    9    14    > > FE_RESET_R                                           $10     !0, ->21
         15    > > FE_FETCH_R                                                   $10, !3, ->21
         16    >   INIT_FCALL                                                   'error_log'
         17        FETCH_DIM_R                                          ~11     !3, 'x'
         18        SEND_VAL                                                     ~11
         19        DO_ICALL                                                     
         20      > JMP                                                          ->15
         21    >   FE_FREE                                                      $10
   10    22      > JMP                                                          ->24
    8    23*       JMP                                                          ->13
         24    >   FE_FREE                                                      $9
   11    25      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
128.1 ms | 480 KiB | 9 Q