3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['Rank' => 7, 'Suit' => 'Hearts'], ['Rank' => 3, 'Suit' => 'Hearts'], ['Rank' => 6, 'Suit' => 'Spades'], ['Rank' => 10, 'Suit' => 'Spades'], ['Rank' => 3, 'Suit' => 'Spades'], ['Rank' => 6, 'Suit' => 'Hearts'], ['Rank' => 2, 'Suit' => 'Clubs'], ]; $rankCounts = array_count_values(array_column($array, 'Rank')); usort( $array, function($a, $b) use ($rankCounts) { return [$rankCounts[$b['Rank']], $b['Rank']] <=> [$rankCounts[$a['Rank']], $a['Rank']]; } ); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YAMYc
function name:  (null)
number of ops:  19
compiled vars:  !0 = $array, !1 = $rankCounts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'array_count_values'
          2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'Rank'
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !1, $4
   13     9        INIT_FCALL                                               'usort'
   14    10        SEND_REF                                                 !0
   15    11        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
         12        BIND_LEXICAL                                             ~6, !1
   17    13        SEND_VAL                                                 ~6
   13    14        DO_ICALL                                                 
   20    15        INIT_FCALL                                               'var_export'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                                 
         18      > 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/YAMYc
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b, !2 = $rankCounts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   16     3        FETCH_DIM_R                                      ~3      !1, 'Rank'
          4        FETCH_DIM_R                                      ~4      !2, ~3
          5        INIT_ARRAY                                       ~5      ~4
          6        FETCH_DIM_R                                      ~6      !1, 'Rank'
          7        ADD_ARRAY_ELEMENT                                ~5      ~6
          8        FETCH_DIM_R                                      ~7      !0, 'Rank'
          9        FETCH_DIM_R                                      ~8      !2, ~7
         10        INIT_ARRAY                                       ~9      ~8
         11        FETCH_DIM_R                                      ~10     !0, 'Rank'
         12        ADD_ARRAY_ELEMENT                                ~9      ~10
         13        SPACESHIP                                        ~11     ~5, ~9
         14      > RETURN                                                   ~11
   17    15*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.87 ms | 1002 KiB | 17 Q