3v4l.org

run code in 300+ PHP versions simultaneously
<?php $A = array( 'Z'=>array('d'=>array( 'v1'=>10, 'v2'=>20, 'v3'=>30 ) ), 'A'=>array('a'=>array( 'v1'=>1, 'v2'=>2, 'v3'=>3 ), 'b'=>array( 'v1'=>1, 'v2'=>2, 'v3'=>3 ) ), 'B'=>array('a'=>array( 'v1'=>1, 'v2'=>2, 'v3'=>3 ), 'b'=>array( 'v1'=>1, 'v2'=>2, 'v3'=>3 ) ), 'C'=>array('a'=>array( 'v1'=>9, 'v2'=>8, 'v3'=>7 ), 'b'=>array( 'v1'=>6, 'v2'=>5, 'v3'=>4 ) ) ); $total=array_reduce($A,function(&$r,$v){ array_walk($v,function($val,$key)use(&$r){ if(!isset($r[$key])) $r[$key]=array(); array_walk($val,function($vv,$vk)use(&$r,$key){ if(!isset($r[$key][$vk])) $r[$key][$vk]=0; $r[$key][$vk]+=$vv; }); }); return $r; },array()); print_r($total);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8vZp4
function name:  (null)
number of ops:  12
compiled vars:  !0 = $A, !1 = $total
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   47     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8vZp4%3A47%240'
   56     4        SEND_VAL                                                 ~3
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                         $4      
   47     7        ASSIGN                                                   !1, $4
   57     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F8vZp4%3A47%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8vZp4
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $r, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   48     2        INIT_FCALL                                               'array_walk'
          3        SEND_REF                                                 !1
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8vZp4%3A48%241'
          5        BIND_LEXICAL                                             ~2, !0
   54     6        SEND_VAL                                                 ~2
          7        DO_ICALL                                                 
   55     8      > RETURN                                                   !0
   56     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8vZp4%3A47%240

Function %00%7Bclosure%7D%2Fin%2F8vZp4%3A48%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/8vZp4
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $val, !1 = $key, !2 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   49     3        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      !2, !1
          4        BOOL_NOT                                         ~4      ~3
          5      > JMPZ                                                     ~4, ->8
          6    >   ASSIGN_DIM                                               !2, !1
          7        OP_DATA                                                  <array>
   50     8    >   INIT_FCALL                                               'array_walk'
          9        SEND_REF                                                 !0
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8vZp4%3A50%242'
         11        BIND_LEXICAL                                             ~6, !2
         12        BIND_LEXICAL                                             ~6, !1
   53    13        SEND_VAL                                                 ~6
         14        DO_ICALL                                                 
   54    15      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8vZp4%3A48%241

Function %00%7Bclosure%7D%2Fin%2F8vZp4%3A50%242:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/8vZp4
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $vv, !1 = $vk, !2 = $r, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   51     4        FETCH_DIM_IS                                     ~4      !2, !3
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~5      ~4, !1
          6        BOOL_NOT                                         ~6      ~5
          7      > JMPZ                                                     ~6, ->11
          8    >   FETCH_DIM_W                                      $7      !2, !3
          9        ASSIGN_DIM                                               $7, !1
         10        OP_DATA                                                  0
   52    11    >   FETCH_DIM_RW                                     $9      !2, !3
         12        ASSIGN_DIM_OP                +=               1          $9, !1
         13        OP_DATA                                                  !0
   53    14      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8vZp4%3A50%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
196.08 ms | 1400 KiB | 19 Q