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); });*/ $result = array(); foreach($menu as $m) { if (!isset($result[$m[1]])) { $result[$m[1]] = array(); } $result[$m[1]][] = $m; } print_r($result); //$result = m($menu, 0, 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/FsDGd
function name:  (null)
number of ops:  26
compiled vars:  !0 = $menu, !1 = $result, !2 = $m, !3 = $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                                       $6      !0, ->16
          3    > > FE_FETCH_R                                               $6, !2, ->16
   26     4    >   FETCH_DIM_R                                      ~7      !2, 1
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !1, ~7
          6        BOOL_NOT                                         ~9      ~8
          7      > JMPZ                                                     ~9, ->11
   27     8    >   FETCH_DIM_R                                      ~10     !2, 1
          9        ASSIGN_DIM                                               !1, ~10
         10        OP_DATA                                                  <array>
   29    11    >   FETCH_DIM_R                                      ~12     !2, 1
         12        FETCH_DIM_W                                      $13     !1, ~12
         13        ASSIGN_DIM                                               $13
         14        OP_DATA                                                  !2
   25    15      > JMP                                                      ->3
         16    >   FE_FREE                                                  $6
   32    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                                 
   38    20        ASSIGN                                                   !3, <array>
   50    21        INIT_FCALL                                               'var_dump'
         22        IS_EQUAL                                         ~17     !1, !3
         23        SEND_VAL                                                 ~17
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.52 ms | 1395 KiB | 17 Q