3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ ['type' => 1, 'text' => 'A'], ['type' => 2, 'text' => 'B'], ['type' => 2, 'text' => 'C'], ['type' => 3, 'text' => 'D'], ['type' => 2, 'text' => 'E'], ['type' => 1, 'text' => 'F'], ['type' => 4, 'text' => 'G'], ['type' => 2, 'text' => 'H'], ['type' => 1, 'text' => 'I'], ['type' => 4, 'text' => 'J'], ['type' => 2, 'text' => 'K'], ['type' => 4, 'text' => 'L'], ['type' => 2, 'text' => 'M'], ['type' => 3, 'text' => 'N'], ['type' => 3, 'text' => 'O'], ['type' => 1, 'text' => 'P'], ['type' => 1, 'text' => 'Q'], ['type' => 2, 'text' => 'R'], ['type' => 3, 'text' => 'S'], ['type' => 2, 'text' => 'T'], ['type' => 3, 'text' => 'U'], ['type' => 2, 'text' => 'V'], ['type' => 3, 'text' => 'W'], ['type' => 2, 'text' => 'X'], ['type' => 4, 'text' => 'Y'], ['type' => 2, 'text' => 'Z'], ]; $maxConsecutive = 3; $grouper = []; $column = []; foreach ($items as $row) { $column[] = $row['type']; $encountered[$row['type']] ??= 0; $grouper[] = intdiv($encountered[$row['type']], $maxConsecutive); ++$encountered[$row['type']]; } array_multisort($grouper, $column, $items); var_export($items);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 31
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 31
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/EGY6b
function name:  (null)
number of ops:  41
compiled vars:  !0 = $items, !1 = $maxConsecutive, !2 = $grouper, !3 = $column, !4 = $row, !5 = $encountered
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   32     1        ASSIGN                                                   !1, 3
   34     2        ASSIGN                                                   !2, <array>
   35     3        ASSIGN                                                   !3, <array>
   36     4      > FE_RESET_R                                       $10     !0, ->31
          5    > > FE_FETCH_R                                               $10, !4, ->31
   37     6    >   FETCH_DIM_R                                      ~12     !4, 'type'
          7        ASSIGN_DIM                                               !3
          8        OP_DATA                                                  ~12
   38     9        FETCH_DIM_R                                      ~13     !4, 'type'
         10        COPY_TMP                                         ~14     ~13
         11        FETCH_DIM_IS                                     ~15     !5, ~13
         12        COALESCE                                         ~16     ~15
         13        ASSIGN_DIM                                       ~17     !5, ~14
         14        OP_DATA                                                  0
         15        QM_ASSIGN                                        ~16     ~17
         16      > JMP                                                      ->18
         17*       FREE                                                     ~14
         18    >   FREE                                                     ~16
   39    19        INIT_FCALL                                               'intdiv'
         20        FETCH_DIM_R                                      ~19     !4, 'type'
         21        FETCH_DIM_R                                      ~20     !5, ~19
         22        SEND_VAL                                                 ~20
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $21     
         25        ASSIGN_DIM                                               !2
         26        OP_DATA                                                  $21
   40    27        FETCH_DIM_R                                      ~22     !4, 'type'
         28        FETCH_DIM_RW                                     $23     !5, ~22
         29        PRE_INC                                                  $23
   36    30      > JMP                                                      ->5
         31    >   FE_FREE                                                  $10
   43    32        INIT_FCALL                                               'array_multisort'
         33        SEND_REF                                                 !2
         34        SEND_REF                                                 !3
         35        SEND_REF                                                 !0
         36        DO_ICALL                                                 
   45    37        INIT_FCALL                                               'var_export'
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.56 ms | 1005 KiB | 16 Q