3v4l.org

run code in 300+ PHP versions simultaneously
<?php $e = array('a' => array(1),'b' =>array(1)); foreach($e as $name => $arr) { if ($name == 'b'){ $e[$name] = adder($arr); } } var_dump($e); function adder($carr) { $carr["stuff"] = array("123"); return $carr; // should show array $e with new array added to 'b' }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/XaquJ
function name:  (null)
number of ops:  17
compiled vars:  !0 = $e, !1 = $arr, !2 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1      > FE_RESET_R                                       $4      !0, ->12
          2    > > FE_FETCH_R                                       ~5      $4, !1, ->12
          3    >   ASSIGN                                                   !2, ~5
    6     4        IS_EQUAL                                                 !2, 'b'
          5      > JMPZ                                                     ~7, ->11
    7     6    >   INIT_FCALL_BY_NAME                                       'adder'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $9      
          9        ASSIGN_DIM                                               !0, !2
         10        OP_DATA                                                  $9
    4    11    > > JMP                                                      ->2
         12    >   FE_FREE                                                  $4
   11    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
   17    16      > RETURN                                                   1

Function adder:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XaquJ
function name:  adder
number of ops:  5
compiled vars:  !0 = $carr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        ASSIGN_DIM                                               !0, 'stuff'
          2        OP_DATA                                                  <array>
   16     3      > RETURN                                                   !0
   17     4*     > RETURN                                                   null

End of function adder

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.39 ms | 1395 KiB | 15 Q