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 $result = array(); $tmp = array(); foreach ($menu as $index => $val ) { $tmp[$val[1]][$val[4]] = $index; } ksort($tmp); print_r($tmp); $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 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/W5YGP
function name:  (null)
number of ops:  21
compiled vars:  !0 = $menu, !1 = $result, !2 = $tmp, !3 = $val, !4 = $index, !5 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, <array>
   18     2        ASSIGN                                                   !2, <array>
   19     3      > FE_RESET_R                                       $9      !0, ->12
          4    > > FE_FETCH_R                                       ~10     $9, !3, ->12
          5    >   ASSIGN                                                   !4, ~10
   20     6        FETCH_DIM_R                                      ~12     !3, 1
          7        FETCH_DIM_R                                      ~14     !3, 4
          8        FETCH_DIM_W                                      $13     !2, ~12
          9        ASSIGN_DIM                                               $13, ~14
         10        OP_DATA                                                  !4
   19    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $9
   24    13        INIT_FCALL                                               'ksort'
         14        SEND_REF                                                 !2
         15        DO_ICALL                                                 
   26    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   28    19        ASSIGN                                                   !5, <array>
   40    20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.39 ms | 1395 KiB | 17 Q