3v4l.org

run code in 500+ PHP versions simultaneously
<?php $counted_array = [ ["ELA-2", 7], ["Science-3", 9], ["ELA-1", 5], ["Science-2", 9], ["ELA-4", 2], ["ELA-3", 7], ["Science-4", 2], ["Science-1", 1] ]; $assoc_array = array_map( function($subarray){ return array_combine( ['Subject', 'Level'], explode('-', $subarray[0], 2) ) + ['Count' => $subarray[1]]; }, $counted_array ); usort($assoc_array, function($a, $b) { return [$a['Subject'], $a['Level']] <=> [$b['Subject'], $b['Level']]; }); var_export($assoc_array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b5No7
function name:  (null)
number of ops:  16
compiled vars:  !0 = $counted_array, !1 = $assoc_array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   13     1        INIT_FCALL                                                   'array_map'
   14     2        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
   19     3        SEND_VAL                                                     ~3
   20     4        SEND_VAR                                                     !0
   13     5        DO_ICALL                                             $4      
          6        ASSIGN                                                       !1, $4
   23     7        INIT_FCALL                                                   'usort'
          8        SEND_REF                                                     !1
          9        DECLARE_LAMBDA_FUNCTION                              ~6      [1]
   27    10        SEND_VAL                                                     ~6
   23    11        DO_ICALL                                                     
   29    12        INIT_FCALL                                                   'var_export'
         13        SEND_VAR                                                     !1
         14        DO_ICALL                                                     
         15      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b5No7
function name:  {closure:/in/b5No7:14}
number of ops:  16
compiled vars:  !0 = $subarray
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   15     1        INIT_FCALL                                                   'array_combine'
   16     2        SEND_VAL                                                     <array>
          3        INIT_FCALL                                                   'explode'
          4        SEND_VAL                                                     '-'
          5        FETCH_DIM_R                                          ~1      !0, 0
          6        SEND_VAL                                                     ~1
          7        SEND_VAL                                                     2
          8        DO_ICALL                                             $2      
          9        SEND_VAR                                                     $2
   15    10        DO_ICALL                                             $3      
   18    11        FETCH_DIM_R                                          ~4      !0, 1
         12        INIT_ARRAY                                           ~5      ~4, 'Count'
         13        ADD                                                  ~6      $3, ~5
         14      > RETURN                                                       ~6
   19    15*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b5No7
function name:  {closure:/in/b5No7:23}
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   24     2        FETCH_DIM_R                                          ~2      !0, 'Subject'
          3        INIT_ARRAY                                           ~3      ~2
          4        FETCH_DIM_R                                          ~4      !0, 'Level'
          5        ADD_ARRAY_ELEMENT                                    ~3      ~4
   26     6        FETCH_DIM_R                                          ~5      !1, 'Subject'
          7        INIT_ARRAY                                           ~6      ~5
          8        FETCH_DIM_R                                          ~7      !1, 'Level'
          9        ADD_ARRAY_ELEMENT                                    ~6      ~7
         10        SPACESHIP                                            ~8      ~3, ~6
         11      > RETURN                                                       ~8
   27    12*     > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
181.59 ms | 2250 KiB | 18 Q