3v4l.org

run code in 300+ PHP versions simultaneously
<?php $menu = array( array(1,3,'Wurm 1.1', 2, 10), array(2,6,'Vogel 2.1', 2, 30), array(3,0,'Tiger 1', 1, 10), array(4,6,'Hund 2.2', 2, 40), array(5,3,'Katze 1.2', 2, 11), array(6,0,'Pferd 2', 1, 20), array(7,1,'Baer 1.1.1', 3, 0), array(8,3,'Schwein 1.3', 2, 12), array(9,4,'Esel 2.2.1', 3, 0), ); // Algorithmus hier /* uasort($menu, function($a,$b) { return $a[1] == $b[1] ? ($a[4] < $b[4] ? -1 : 1) : ($a[1] < $b[1] ? -1 : 1); });*/ $cache = array(); foreach ($menu as $m) { if (!isset($result[$m[1]])) { $cache[$m[1]] = array(); } $cache[$m[1]][] = $m; } $iterator = sort(array_keys($cache)); print_r($iterator); //$result = m($menu, 0, array()); $result = array(); $target = array( array(3,0,'Tiger 1', 1, 10), array(1,3,'Wurm 1.1', 2, 10), array(7,1,'Baer 1.1.1', 3, 0), array(5,3,'Katze 1.2', 2, 11), array(8,3,'Schwein 1.3', 2, 12), array(6,0,'Pferd 2', 1, 20), array(2,6,'Vogel 2.1', 2, 30), array(4,6,'Hund 2.2', 2, 40), array(9,4,'Esel 2.2.1', 3, 0), ); var_dump($result == $target);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/rfFCe
function name:  (null)
number of ops:  34
compiled vars:  !0 = $menu, !1 = $cache, !2 = $m, !3 = $result, !4 = $iterator, !5 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   23     1        ASSIGN                                                   !1, <array>
   25     2      > FE_RESET_R                                       $8      !0, ->16
          3    > > FE_FETCH_R                                               $8, !2, ->16
   26     4    >   FETCH_DIM_R                                      ~9      !2, 1
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !3, ~9
          6        BOOL_NOT                                         ~11     ~10
          7      > JMPZ                                                     ~11, ->11
   27     8    >   FETCH_DIM_R                                      ~12     !2, 1
          9        ASSIGN_DIM                                               !1, ~12
         10        OP_DATA                                                  <array>
   29    11    >   FETCH_DIM_R                                      ~14     !2, 1
         12        FETCH_DIM_W                                      $15     !1, ~14
         13        ASSIGN_DIM                                               $15
         14        OP_DATA                                                  !2
   25    15      > JMP                                                      ->3
         16    >   FE_FREE                                                  $8
   32    17        INIT_FCALL                                               'sort'
         18        INIT_FCALL                                               'array_keys'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $17     
         21        SEND_VAR_NO_REF                               0          $17
         22        DO_ICALL                                         $18     
         23        ASSIGN                                                   !4, $18
   34    24        INIT_FCALL                                               'print_r'
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                                 
   38    27        ASSIGN                                                   !3, <array>
   40    28        ASSIGN                                                   !5, <array>
   52    29        INIT_FCALL                                               'var_dump'
         30        IS_EQUAL                                         ~23     !3, !5
         31        SEND_VAL                                                 ~23
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.08 ms | 1396 KiB | 21 Q