3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['foo'=>1, 'bar'=>2]; $last = $current = memory_get_usage(); foreach($array as $k=>&$v) { $last = $current; $current = memory_get_usage(); echo "Diff is " . ($current - $last) . "\n"; $array['baz']=3; $last = $current; $current = memory_get_usage(); echo "Diff is " . ($current - $last) . "\n"; echo $v . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 6, Position 2 = 29
Branch analysis from position: 6
2 jumps found. (Code = 126) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/B2W2t
function name:  (null)
number of ops:  31
compiled vars:  !0 = $array, !1 = $last, !2 = $current, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'memory_get_usage'
          2        DO_ICALL                                         $6      
          3        ASSIGN                                           ~7      !2, $6
          4        ASSIGN                                                   !1, ~7
    6     5      > FE_RESET_RW                                      $9      !0, ->29
          6    > > FE_FETCH_RW                                      ~10     $9, !3, ->29
          7    >   ASSIGN                                                   !4, ~10
    8     8        ASSIGN                                                   !1, !2
    9     9        INIT_FCALL                                               'memory_get_usage'
         10        DO_ICALL                                         $13     
         11        ASSIGN                                                   !2, $13
   10    12        SUB                                              ~15     !2, !1
         13        CONCAT                                           ~16     'Diff+is+', ~15
         14        CONCAT                                           ~17     ~16, '%0A'
         15        ECHO                                                     ~17
   12    16        ASSIGN_DIM                                               !0, 'baz'
         17        OP_DATA                                                  3
   13    18        ASSIGN                                                   !1, !2
   14    19        INIT_FCALL                                               'memory_get_usage'
         20        DO_ICALL                                         $20     
         21        ASSIGN                                                   !2, $20
   15    22        SUB                                              ~22     !2, !1
         23        CONCAT                                           ~23     'Diff+is+', ~22
         24        CONCAT                                           ~24     ~23, '%0A'
         25        ECHO                                                     ~24
   17    26        CONCAT                                           ~25     !3, '%0A'
         27        ECHO                                                     ~25
    6    28      > JMP                                                      ->6
         29    >   FE_FREE                                                  $9
   18    30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.62 ms | 1396 KiB | 15 Q