3v4l.org

run code in 300+ PHP versions simultaneously
<?php $scores = array( array(1, "allan", 90), array(2, "allan", 85), array(3, "mark", 100), array(4, "jason", 88), array(5, "allan", 92), array(6, "mark", 77), array(7, "mark", 88), array(8, "jason", 90) ); $scores = array_reduce($scores, function ($c, $v) { $name = $v[1]; if (isset($c[$name])) { $c[$name] += $v[2]; } else { $c[$name] = $v[2]; } return $c; }, array()); arsort($scores); echo key($scores);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rZ4SY
function name:  (null)
number of ops:  16
compiled vars:  !0 = $scores
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   23     4        SEND_VAL                                                 ~2
          5        SEND_VAL                                                 <array>
   14     6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
   25     8        INIT_FCALL                                               'arsort'
          9        SEND_REF                                                 !0
         10        DO_ICALL                                                 
   26    11        INIT_FCALL                                               'key'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $6      
         14        ECHO                                                     $6
         15      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rZ4SY
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $c, !1 = $v, !2 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        FETCH_DIM_R                                      ~3      !1, 1
          3        ASSIGN                                                   !2, ~3
   16     4        ISSET_ISEMPTY_DIM_OBJ                         0          !0, !2
          5      > JMPZ                                                     ~5, ->10
   17     6    >   FETCH_DIM_R                                      ~7      !1, 2
          7        ASSIGN_DIM_OP                +=               1          !0, !2
          8        OP_DATA                                                  ~7
   16     9      > JMP                                                      ->13
   20    10    >   FETCH_DIM_R                                      ~9      !1, 2
         11        ASSIGN_DIM                                               !0, !2
         12        OP_DATA                                                  ~9
   22    13    > > RETURN                                                   !0
   23    14*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.83 ms | 1013 KiB | 16 Q