3v4l.org

run code in 500+ PHP versions simultaneously
<?php $text = '[HEAD] [TITLE-MAIN] example news1 [TITLE-SUB] title sub1 [CONTENT] content text1 [HEAD] [TITLE-MAIN] example news2 [TITLE-SUB] title sub2 [CONTENT] content text2'; $sections = array(); foreach (preg_split('/\s*\[HEAD\]\s*/', $text, -1, PREG_SPLIT_NO_EMPTY) as $section) { $s = trim($section); $tag_data = preg_split('/\[([^\]]+)\]/', $s, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); for ($i = 0; $i < count($tag_data); $i += 2) { $tags[$tag_data[$i]] = trim($tag_data[$i+1]); } $sections[] = $tags; } print_r($sections);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 34
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 34
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 21
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 21
Branch analysis from position: 31
Branch analysis from position: 21
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/347Pu
function name:  (null)
number of ops:  39
compiled vars:  !0 = $text, !1 = $sections, !2 = $section, !3 = $s, !4 = $tag_data, !5 = $i, !6 = $tags
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%5BHEAD%5D%0A%0A%5BTITLE-MAIN%5D%0A%0Aexample+news1%0A%0A%5BTITLE-SUB%5D%0A%0Atitle+sub1%0A%0A%5BCONTENT%5D%0A%0Acontent+text1%0A%0A%0A%5BHEAD%5D%0A%0A%5BTITLE-MAIN%5D%0A%0Aexample+news2%0A%0A%5BTITLE-SUB%5D%0A%0Atitle+sub2%0A%0A%5BCONTENT%5D%0A%0Acontent+text2'
   32     1        ASSIGN                                                       !1, <array>
   33     2        INIT_FCALL                                                   'preg_split'
          3        SEND_VAL                                                     '%2F%5Cs%2A%5C%5BHEAD%5C%5D%5Cs%2A%2F'
          4        SEND_VAR                                                     !0
          5        SEND_VAL                                                     -1
          6        SEND_VAL                                                     1
          7        DO_ICALL                                             $9      
          8      > FE_RESET_R                                           $10     $9, ->34
          9    > > FE_FETCH_R                                                   $10, !2, ->34
   34    10    >   FRAMELESS_ICALL_1                trim                ~11     !2
         11        ASSIGN                                                       !3, ~11
   35    12        INIT_FCALL                                                   'preg_split'
         13        SEND_VAL                                                     '%2F%5C%5B%28%5B%5E%5C%5D%5D%2B%29%5C%5D%2F'
         14        SEND_VAR                                                     !3
         15        SEND_VAL                                                     -1
         16        SEND_VAL                                                     3
         17        DO_ICALL                                             $13     
         18        ASSIGN                                                       !4, $13
   36    19        ASSIGN                                                       !5, 0
         20      > JMP                                                          ->28
   37    21    >   FETCH_DIM_R                                          ~16     !4, !5
         22        ADD                                                  ~18     !5, 1
         23        FETCH_DIM_R                                          ~19     !4, ~18
         24        FRAMELESS_ICALL_1                trim                ~20     ~19
         25        ASSIGN_DIM                                                   !6, ~16
         26        OP_DATA                                                      ~20
   36    27        ASSIGN_OP                                         1          !5, 2
         28    >   COUNT                                                ~22     !4
         29        IS_SMALLER                                                   !5, ~22
         30      > JMPNZ                                                        ~23, ->21
   39    31    >   ASSIGN_DIM                                                   !1
         32        OP_DATA                                                      !6
   33    33      > JMP                                                          ->9
         34    >   FE_FREE                                                      $10
   41    35        INIT_FCALL                                                   'print_r'
         36        SEND_VAR                                                     !1
         37        DO_ICALL                                                     
         38      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
1609.46 ms | 2185 KiB | 15 Q