3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = "Football / Germany / 1.Liga Football / Germany / 1.Liga Football / Germany / 2.Liga Football / Germany / 2.Liga Football / Germany / 2.Liga Football / England / 1.Liga Football / England / 1.Liga Football / England / 2.Liga Football / England / 2.Liga Football / England / 3.Liga Hockey / Germany / 1.Liga Hockey / Germany / 1.Liga Hockey / Germany / 2.Liga Fechten / Meisterschaft Fechten / Meisterschaft Fechten / Weltmeister"; $lines = explode("\n", $strings); $array = array(); $depth = 0; foreach($lines as $line) { $values = explode(' / ', $line); // find out how deep we have to go if(count($values) > $depth) { $depth = count($values) - 1; } } for($i = 0; $i < $depth; $i++) { // run through lines foreach($lines as $line) { $values = explode(' / ', $line); if(isset($values[$i]) && !in_array($values[$i], $array)) $array[] = $values[$i]; } } var_dump($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 22
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 21
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 25
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 46
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 46
Branch analysis from position: 27
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 41
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 45
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 45
Branch analysis from position: 41
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 25
Branch analysis from position: 50
Branch analysis from position: 25
Branch analysis from position: 46
Branch analysis from position: 22
filename:       /in/n1QTo
function name:  (null)
number of ops:  54
compiled vars:  !0 = $strings, !1 = $lines, !2 = $array, !3 = $depth, !4 = $line, !5 = $values, !6 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'Football+%2F+Germany+%2F+1.Liga%0AFootball+%2F+Germany+%2F+1.Liga%0AFootball+%2F+Germany+%2F+2.Liga%0AFootball+%2F+Germany+%2F+2.Liga%0AFootball+%2F+Germany+%2F+2.Liga%0AFootball+%2F+England+%2F+1.Liga%0AFootball+%2F+England+%2F+1.Liga%0AFootball+%2F+England+%2F+2.Liga%0AFootball+%2F+England+%2F+2.Liga%0AFootball+%2F+England+%2F+3.Liga%0AHockey+%2F+Germany+%2F+1.Liga%0AHockey+%2F+Germany+%2F+1.Liga%0AHockey+%2F+Germany+%2F+2.Liga%0AFechten+%2F+Meisterschaft%0AFechten+%2F+Meisterschaft%0AFechten+%2F+Weltmeister'
   19     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   20     6        ASSIGN                                                   !2, <array>
   22     7        ASSIGN                                                   !3, 0
   23     8      > FE_RESET_R                                       $12     !1, ->22
          9    > > FE_FETCH_R                                               $12, !4, ->22
   24    10    >   INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '+%2F+'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $13     
         14        ASSIGN                                                   !5, $13
   26    15        COUNT                                            ~15     !5
         16        IS_SMALLER                                               !3, ~15
         17      > JMPZ                                                     ~16, ->21
   27    18    >   COUNT                                            ~17     !5
         19        SUB                                              ~18     ~17, 1
         20        ASSIGN                                                   !3, ~18
   23    21    > > JMP                                                      ->9
         22    >   FE_FREE                                                  $12
   31    23        ASSIGN                                                   !6, 0
         24      > JMP                                                      ->48
   33    25    > > FE_RESET_R                                       $21     !1, ->46
         26    > > FE_FETCH_R                                               $21, !4, ->46
   34    27    >   INIT_FCALL                                               'explode'
         28        SEND_VAL                                                 '+%2F+'
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                         $22     
         31        ASSIGN                                                   !5, $22
   35    32        ISSET_ISEMPTY_DIM_OBJ                         0  ~24     !5, !6
         33      > JMPZ_EX                                          ~24     ~24, ->41
         34    >   INIT_FCALL                                               'in_array'
         35        FETCH_DIM_R                                      ~25     !5, !6
         36        SEND_VAL                                                 ~25
         37        SEND_VAR                                                 !2
         38        DO_ICALL                                         $26     
         39        BOOL_NOT                                         ~27     $26
         40        BOOL                                             ~24     ~27
         41    > > JMPZ                                                     ~24, ->45
         42    >   FETCH_DIM_R                                      ~29     !5, !6
         43        ASSIGN_DIM                                               !2
         44        OP_DATA                                                  ~29
   33    45    > > JMP                                                      ->26
         46    >   FE_FREE                                                  $21
   31    47        PRE_INC                                                  !6
         48    >   IS_SMALLER                                               !6, !3
         49      > JMPNZ                                                    ~31, ->25
   39    50    >   INIT_FCALL                                               'var_dump'
         51        SEND_VAR                                                 !2
         52        DO_ICALL                                                 
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.39 ms | 1400 KiB | 19 Q