3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! $arr = array(10,8,13,8,5,10,10,12); $occurrences = array_count_values($arr); usort($arr, function ($a, $b) use ($occurrences) { // if the occurrence is equal (== 0), return value difference instead return ($occurrences[$a] - $occurrences[$b]) ?: ($a - $b); }); print_r($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FsDTG
function name:  (null)
number of ops:  15
compiled vars:  !0 = $arr, !1 = $occurrences
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    6     1        INIT_FCALL                                               'array_count_values'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
    7     5        INIT_FCALL                                               'usort'
          6        SEND_REF                                                 !0
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FFsDTG%3A7%240'
          8        BIND_LEXICAL                                             ~5, !1
   10     9        SEND_VAL                                                 ~5
         10        DO_ICALL                                                 
   12    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FFsDTG%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FsDTG
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $a, !1 = $b, !2 = $occurrences
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    9     3        FETCH_DIM_R                                      ~3      !2, !0
          4        FETCH_DIM_R                                      ~4      !2, !1
          5        SUB                                              ~5      ~3, ~4
          6        JMP_SET                                          ~6      ~5, ->9
          7        SUB                                              ~7      !0, !1
          8        QM_ASSIGN                                        ~6      ~7
          9      > RETURN                                                   ~6
   10    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FFsDTG%3A7%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.23 ms | 1399 KiB | 19 Q