3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$array = ["05h", "02h", "03c", "02s", "04h"]; //$array = ["05h", "02h", "03c", "02s", "03h"]; $array = ["03s", "02h", "03c", "02s", "03h"]; foreach ($array as $v) { $num = (int) $v; $counts[$num] = ($counts[$num] ?? 0) + 1; $map[$v] =& $counts[$num]; } var_dump($map); usort($array, fn($a, $b) => $map[$b] <=> $map[$a]); var_export($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/Sl1b8
function name:  (null)
number of ops:  30
compiled vars:  !0 = $array, !1 = $v, !2 = $num, !3 = $counts, !4 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
    7     1      > FE_RESET_R                                       $6      !0, ->16
          2    > > FE_FETCH_R                                               $6, !1, ->16
    8     3    >   CAST                                          4  ~7      !1
          4        ASSIGN                                                   !2, ~7
    9     5        FETCH_DIM_IS                                     ~10     !3, !2
          6        COALESCE                                         ~11     ~10
          7        QM_ASSIGN                                        ~11     0
          8        ADD                                              ~12     ~11, 1
          9        ASSIGN_DIM                                               !3, !2
         10        OP_DATA                                                  ~12
   10    11        FETCH_DIM_W                                      $14     !3, !2
         12        MAKE_REF                                         $15     $14
         13        FETCH_DIM_W                                      $13     !4, !1
         14        ASSIGN_REF                                               $13, $15
    7    15      > JMP                                                      ->2
         16    >   FE_FREE                                                  $6
   12    17        INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !4
         19        DO_ICALL                                                 
   13    20        INIT_FCALL                                               'usort'
         21        SEND_REF                                                 !0
         22        DECLARE_LAMBDA_FUNCTION                          ~18     [0]
         23        BIND_LEXICAL                                             ~18, !4
         24        SEND_VAL                                                 ~18
         25        DO_ICALL                                                 
   14    26        INIT_FCALL                                               'var_export'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
         29      > 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/Sl1b8
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $a, !1 = $b, !2 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        FETCH_DIM_R                                      ~3      !2, !1
          4        FETCH_DIM_R                                      ~4      !2, !0
          5        SPACESHIP                                        ~5      ~3, ~4
          6      > RETURN                                                   ~5
          7*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.23 ms | 1012 KiB | 16 Q