3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "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"; class ArrayStacker { public function stackArray($string) { $array = $this->splitString($string); die(var_dump($array)); } /** * Split the whole string into a big array * * @param string $string * @return array */ protected function splitString($string) { $lines = explode("\n", $string); $i = 0; $array = array(); foreach($lines as $line) { $values = explode(' / ', $line); foreach($values as $v => $value) { $values[$v] = trim($value); // make sure we got no whitespaces } $array[$i] = $values; } return $array; } } $arrayStacker = new ArrayStacker(); $arrayStacker->stackArray($string);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3KhXb
function name:  (null)
number of ops:  8
compiled vars:  !0 = $string, !1 = $arrayStacker
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'
   46     1        NEW                                              $3      'ArrayStacker'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   47     4        INIT_METHOD_CALL                                         !1, 'stackArray'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Class ArrayStacker:
Function stackarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/3KhXb
function name:  stackArray
number of ops:  10
compiled vars:  !0 = $string, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_METHOD_CALL                                         'splitString'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !1, $2
   22     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $4      
          8      > EXIT                                                     $4
   23     9*     > RETURN                                                   null

End of function stackarray

Function splitstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 28
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 28
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 24
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/3KhXb
function name:  splitString
number of ops:  31
compiled vars:  !0 = $string, !1 = $lines, !2 = $i, !3 = $array, !4 = $line, !5 = $values, !6 = $value, !7 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
   32     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   33     6        ASSIGN                                                   !2, 0
   34     7        ASSIGN                                                   !3, <array>
   35     8      > FE_RESET_R                                       $12     !1, ->28
          9    > > FE_FETCH_R                                               $12, !4, ->28
   36    10    >   INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '+%2F+'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $13     
         14        ASSIGN                                                   !5, $13
   37    15      > FE_RESET_R                                       $15     !5, ->24
         16    > > FE_FETCH_R                                       ~16     $15, !6, ->24
         17    >   ASSIGN                                                   !7, ~16
   38    18        INIT_FCALL                                               'trim'
         19        SEND_VAR                                                 !6
         20        DO_ICALL                                         $19     
         21        ASSIGN_DIM                                               !5, !7
         22        OP_DATA                                                  $19
   37    23      > JMP                                                      ->16
         24    >   FE_FREE                                                  $15
   40    25        ASSIGN_DIM                                               !3, !2
         26        OP_DATA                                                  !5
   35    27      > JMP                                                      ->9
         28    >   FE_FREE                                                  $12
   42    29      > RETURN                                                   !3
   43    30*     > RETURN                                                   null

End of function splitstring

End of class ArrayStacker.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.46 ms | 1400 KiB | 19 Q