3v4l.org

run code in 500+ 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(); foreach ($menu as $entry) { $result[substr(strrchr($entry[2], ' '), 1)] = $entry; } ksort($result, SORT_NATURAL); $result = array_values($result); $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 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/sSsDC
function name:  (null)
number of ops:  28
compiled vars:  !0 = $menu, !1 = $result, !2 = $entry, !3 = $target
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   16     1        ASSIGN                                                       !1, <array>
   17     2      > FE_RESET_R                                           $6      !0, ->13
          3    > > FE_FETCH_R                                                   $6, !2, ->13
   18     4    >   INIT_FCALL                                                   'strrchr'
          5        FETCH_DIM_R                                          ~7      !2, 2
          6        SEND_VAL                                                     ~7
          7        SEND_VAL                                                     '+'
          8        DO_ICALL                                             $8      
          9        FRAMELESS_ICALL_2                substr              ~9      $8, 1
         10        ASSIGN_DIM                                                   !1, ~9
         11        OP_DATA                                                      !2
   17    12      > JMP                                                          ->3
         13    >   FE_FREE                                                      $6
   20    14        INIT_FCALL                                                   'ksort'
         15        SEND_REF                                                     !1
         16        SEND_VAL                                                     6
         17        DO_ICALL                                                     
   21    18        INIT_FCALL                                                   'array_values'
         19        SEND_VAR                                                     !1
         20        DO_ICALL                                             $12     
         21        ASSIGN                                                       !1, $12
   25    22        ASSIGN                                                       !3, <array>
   37    23        INIT_FCALL                                                   'var_dump'
         24        IS_EQUAL                                             ~15     !1, !3
         25        SEND_VAL                                                     ~15
         26        DO_ICALL                                                     
         27      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.19 ms | 2902 KiB | 17 Q