3v4l.org

run code in 300+ PHP versions simultaneously
<?php function o($num) { return (object) array('num' => $num); } $arr = array( 14 => array('x' => o(1), 'oele' => array(o(1), o(2), o(3), o(4))), 91 => array('x' => o(1), 'oele' => array(o(9), o(8), o(7), o(6))), ); foreach ( $arr as $i => &$session ) { $session['boele']['one'] = 4; // works $session['boele']['two'] = array_reduce($session['oele'], function($sum, $app) use ($session) { return $sum + $app->num * $session['x']->num; }, 0); // don't works unset($session); } print_r($arr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 46, Position 2 = 64
Branch analysis from position: 46
2 jumps found. (Code = 126) Position 1 = 47, Position 2 = 64
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
filename:       /in/t43UP
function name:  (null)
number of ops:  69
compiled vars:  !0 = $arr, !1 = $session, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'o'
          1        SEND_VAL                                                 1
          2        DO_FCALL                                      0  $3      
          3        INIT_ARRAY                                       ~4      $3, 'x'
          4        INIT_FCALL                                               'o'
          5        SEND_VAL                                                 1
          6        DO_FCALL                                      0  $5      
          7        INIT_ARRAY                                       ~6      $5
          8        INIT_FCALL                                               'o'
          9        SEND_VAL                                                 2
         10        DO_FCALL                                      0  $7      
         11        ADD_ARRAY_ELEMENT                                ~6      $7
         12        INIT_FCALL                                               'o'
         13        SEND_VAL                                                 3
         14        DO_FCALL                                      0  $8      
         15        ADD_ARRAY_ELEMENT                                ~6      $8
         16        INIT_FCALL                                               'o'
         17        SEND_VAL                                                 4
         18        DO_FCALL                                      0  $9      
         19        ADD_ARRAY_ELEMENT                                ~6      $9
         20        ADD_ARRAY_ELEMENT                                ~4      ~6, 'oele'
         21        INIT_ARRAY                                       ~10     ~4, 14
    9    22        INIT_FCALL                                               'o'
         23        SEND_VAL                                                 1
         24        DO_FCALL                                      0  $11     
         25        INIT_ARRAY                                       ~12     $11, 'x'
         26        INIT_FCALL                                               'o'
         27        SEND_VAL                                                 9
         28        DO_FCALL                                      0  $13     
         29        INIT_ARRAY                                       ~14     $13
         30        INIT_FCALL                                               'o'
         31        SEND_VAL                                                 8
         32        DO_FCALL                                      0  $15     
         33        ADD_ARRAY_ELEMENT                                ~14     $15
         34        INIT_FCALL                                               'o'
         35        SEND_VAL                                                 7
         36        DO_FCALL                                      0  $16     
         37        ADD_ARRAY_ELEMENT                                ~14     $16
         38        INIT_FCALL                                               'o'
         39        SEND_VAL                                                 6
         40        DO_FCALL                                      0  $17     
         41        ADD_ARRAY_ELEMENT                                ~14     $17
         42        ADD_ARRAY_ELEMENT                                ~12     ~14, 'oele'
         43        ADD_ARRAY_ELEMENT                                ~10     ~12, 91
    7    44        ASSIGN                                                   !0, ~10
   11    45      > FE_RESET_RW                                      $19     !0, ->64
         46    > > FE_FETCH_RW                                      ~20     $19, !1, ->64
         47    >   ASSIGN                                                   !2, ~20
   12    48        FETCH_DIM_W                                      $22     !1, 'boele'
         49        ASSIGN_DIM                                               $22, 'one'
         50        OP_DATA                                                  4
   14    51        INIT_FCALL                                               'array_reduce'
         52        FETCH_DIM_R                                      ~26     !1, 'oele'
         53        SEND_VAL                                                 ~26
         54        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ft43UP%3A14%240'
         55        BIND_LEXICAL                                             ~27, !1
   16    56        SEND_VAL                                                 ~27
         57        SEND_VAL                                                 0
         58        DO_ICALL                                         $28     
   14    59        FETCH_DIM_W                                      $24     !1, 'boele'
         60        ASSIGN_DIM                                               $24, 'two'
   16    61        OP_DATA                                                  $28
   18    62        UNSET_CV                                                 !1
   11    63      > JMP                                                      ->46
         64    >   FE_FREE                                                  $19
   21    65        INIT_FCALL                                               'print_r'
         66        SEND_VAR                                                 !0
         67        DO_ICALL                                                 
         68      > RETURN                                                   1

Function o:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t43UP
function name:  o
number of ops:  5
compiled vars:  !0 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_ARRAY                                       ~1      !0, 'num'
          2        CAST                                          8  ~2      ~1
          3      > RETURN                                                   ~2
    5     4*     > RETURN                                                   null

End of function o

Function %00%7Bclosure%7D%2Fin%2Ft43UP%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t43UP
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $sum, !1 = $app, !2 = $session
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   15     3        FETCH_OBJ_R                                      ~3      !1, 'num'
          4        FETCH_DIM_R                                      ~4      !2, 'x'
          5        FETCH_OBJ_R                                      ~5      ~4, 'num'
          6        MUL                                              ~6      ~3, ~5
          7        ADD                                              ~7      !0, ~6
          8      > RETURN                                                   ~7
   16     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Ft43UP%3A14%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
197.98 ms | 1407 KiB | 27 Q