3v4l.org

run code in 300+ PHP versions simultaneously
<?php $aggs['aggs']['name'] = "name"; function addEnd($item, $key) { echo $item; echo "\n" . $key; if(is_array($item)){ return; }elseif($key=='aggs'){ $item=['name'=> ['aggs' => $item]]; }else{ $item=['aggs' => $item]; } } for($i=0; $i<5; $i++){ // your loop array_walk($aggs, 'addEnd'); } var_dump($aggs);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 5
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 5
Branch analysis from position: 12
Branch analysis from position: 5
filename:       /in/mhfJ7
function name:  (null)
number of ops:  16
compiled vars:  !0 = $aggs, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   FETCH_DIM_W                                      $2      !0, 'aggs'
          1        ASSIGN_DIM                                               $2, 'name'
          2        OP_DATA                                                  'name'
   17     3        ASSIGN                                                   !1, 0
          4      > JMP                                                      ->10
   18     5    >   INIT_FCALL                                               'array_walk'
          6        SEND_REF                                                 !0
          7        SEND_VAL                                                 'addEnd'
          8        DO_ICALL                                                 
   17     9        PRE_INC                                                  !1
         10    >   IS_SMALLER                                               !1, 5
         11      > JMPNZ                                                    ~7, ->5
   21    12    >   INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function addend:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mhfJ7
function name:  addEnd
number of ops:  18
compiled vars:  !0 = $item, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        ECHO                                                     !0
    7     3        CONCAT                                           ~2      '%0A', !1
          4        ECHO                                                     ~2
    8     5        TYPE_CHECK                                  128          !0
          6      > JMPZ                                                     ~3, ->9
    9     7    > > RETURN                                                   null
          8*       JMP                                                      ->17
   10     9    >   IS_EQUAL                                                 !1, 'aggs'
         10      > JMPZ                                                     ~4, ->15
   11    11    >   INIT_ARRAY                                       ~5      !0, 'aggs'
         12        INIT_ARRAY                                       ~6      ~5, 'name'
         13        ASSIGN                                                   !0, ~6
         14      > JMP                                                      ->17
   13    15    >   INIT_ARRAY                                       ~8      !0, 'aggs'
         16        ASSIGN                                                   !0, ~8
   15    17    > > RETURN                                                   null

End of function addend

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.66 ms | 1405 KiB | 17 Q