3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "foo { bar tree; bar ball/sand; snafu { string; } random { nested { value; bohica; } nested again { foo; bar; } } }"; $buf = ""; $brace_level = 0; $words = array(); for ($i = 0; $i < strlen($text); $i++) { switch ($text[$i]) { case '{': $words[$brace_level] = trim($buf); $buf = ""; $brace_level++; break; case '}': $brace_level--; unset($words[$brace_level]); break; case ';': $words[$brace_level] = trim($buf); $buf = ""; ksort($words); print implode(" ", $words)."\n"; break; default: $buf .= $text[$i]; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 6
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
5 jumps found. (Code = 188) Position 1 = 15, Position 2 = 23, Position 3 = 26, Position 4 = 42, Position 5 = 8
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 6
Branch analysis from position: 49
Branch analysis from position: 6
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 6
Branch analysis from position: 49
Branch analysis from position: 6
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 26
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 26
Branch analysis from position: 23
Branch analysis from position: 15
filename:       /in/QkYDc
function name:  (null)
number of ops:  50
compiled vars:  !0 = $text, !1 = $buf, !2 = $brace_level, !3 = $words, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'foo+%7B%0A++++bar+tree%3B%0A++++bar+ball%2Fsand%3B%0A++++snafu+%7B%0A++++++++string%3B%0A++++%7D%0A++++random+%7B%0A++++++++nested+%7B%0A++++++++++++value%3B%0A++++++++++++bohica%3B%0A++++++++%7D%0A%09%09nested+again+%7B%0A%09%09%09foo%3B%0A%09%09%09bar%3B%0A%09%09%7D%0A++++%7D%0A%7D'
   21     1        ASSIGN                                                   !1, ''
   22     2        ASSIGN                                                   !2, 0
   23     3        ASSIGN                                                   !3, <array>
   24     4        ASSIGN                                                   !4, 0
          5      > JMP                                                      ->46
   25     6    >   FETCH_DIM_R                                      ~10     !0, !4
          7      > SWITCH_STRING                                            ~10, [ '%7B':->15, '%7D':->23, '%3B':->26, ], ->42
   26     8    >   CASE                                                     ~10, '%7B'
          9      > JMPNZ                                                    ~11, ->15
   31    10    >   CASE                                                     ~10, '%7D'
         11      > JMPNZ                                                    ~11, ->23
   35    12    >   CASE                                                     ~10, '%3B'
         13      > JMPNZ                                                    ~11, ->26
         14    > > JMP                                                      ->42
   27    15    >   INIT_FCALL                                               'trim'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $13     
         18        ASSIGN_DIM                                               !3, !2
         19        OP_DATA                                                  $13
   28    20        ASSIGN                                                   !1, ''
   29    21        PRE_INC                                                  !2
   30    22      > JMP                                                      ->44
   32    23    >   PRE_DEC                                                  !2
   33    24        UNSET_DIM                                                !3, !2
   34    25      > JMP                                                      ->44
   36    26    >   INIT_FCALL                                               'trim'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $18     
         29        ASSIGN_DIM                                               !3, !2
         30        OP_DATA                                                  $18
   37    31        ASSIGN                                                   !1, ''
   38    32        INIT_FCALL                                               'ksort'
         33        SEND_REF                                                 !3
         34        DO_ICALL                                                 
   39    35        INIT_FCALL                                               'implode'
         36        SEND_VAL                                                 '+'
         37        SEND_VAR                                                 !3
         38        DO_ICALL                                         $21     
         39        CONCAT                                           ~22     $21, '%0A'
         40        ECHO                                                     ~22
   40    41      > JMP                                                      ->44
   42    42    >   FETCH_DIM_R                                      ~23     !0, !4
         43        ASSIGN_OP                                     8          !1, ~23
         44    >   FREE                                                     ~10
   24    45        PRE_INC                                                  !4
         46    >   STRLEN                                           ~26     !0
         47        IS_SMALLER                                               !4, ~26
         48      > JMPNZ                                                    ~27, ->6
   44    49    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.51 ms | 1400 KiB | 19 Q