3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "<div class='room'> <h1>This is a h1</h1> <p>This is a Paragraph</p> <h2>This is h2</h2> </div> <div class='room2'> <h1>This is a h1</h1> <p>This is a Paragraph</p> <h2>This is h2</h2> </div>"; $arr = explode(PHP_EOL, $str); $res =array(); Foreach($arr as $row){ If(strpos($row, "div ") !== False){ $pos1 = strpos($row, "'")+1; $room = substr($row, $pos1, strpos($row, "'", $pos1)-$pos1); }Else{ $pos1 = strpos($row, "<")+1; $res[$room][substr($row, strpos($row, "<")+1, strpos($row, ">")-$pos1)] = trim(strip_tags($row)); } } Var_dump($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 65
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 65
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 34
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
filename:       /in/aolYj
function name:  (null)
number of ops:  70
compiled vars:  !0 = $str, !1 = $arr, !2 = $res, !3 = $row, !4 = $pos1, !5 = $room
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+class%3D%27room%27%3E%0A++++%3Ch1%3EThis+is+a+h1%3C%2Fh1%3E%0A++++%3Cp%3EThis+is+a+Paragraph%3C%2Fp%3E%0A++++%3Ch2%3EThis+is+h2%3C%2Fh2%3E%0A++++%3C%2Fdiv%3E%0A++++%3Cdiv+class%3D%27room2%27%3E%0A++++%3Ch1%3EThis+is+a+h1%3C%2Fh1%3E%0A++++%3Cp%3EThis+is+a+Paragraph%3C%2Fp%3E%0A++++%3Ch2%3EThis+is+h2%3C%2Fh2%3E%0A++++%3C%2Fdiv%3E'
   14     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
   16     6        ASSIGN                                                   !2, <array>
   17     7      > FE_RESET_R                                       $10     !1, ->65
          8    > > FE_FETCH_R                                               $10, !3, ->65
   18     9    >   INIT_FCALL                                               'strpos'
         10        SEND_VAR                                                 !3
         11        SEND_VAL                                                 'div+'
         12        DO_ICALL                                         $11     
         13        TYPE_CHECK                                  1018          $11
         14      > JMPZ                                                     ~12, ->34
   19    15    >   INIT_FCALL                                               'strpos'
         16        SEND_VAR                                                 !3
         17        SEND_VAL                                                 '%27'
         18        DO_ICALL                                         $13     
         19        ADD                                              ~14     $13, 1
         20        ASSIGN                                                   !4, ~14
   20    21        INIT_FCALL                                               'substr'
         22        SEND_VAR                                                 !3
         23        SEND_VAR                                                 !4
         24        INIT_FCALL                                               'strpos'
         25        SEND_VAR                                                 !3
         26        SEND_VAL                                                 '%27'
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                         $16     
         29        SUB                                              ~17     $16, !4
         30        SEND_VAL                                                 ~17
         31        DO_ICALL                                         $18     
         32        ASSIGN                                                   !5, $18
         33      > JMP                                                      ->64
   22    34    >   INIT_FCALL                                               'strpos'
         35        SEND_VAR                                                 !3
         36        SEND_VAL                                                 '%3C'
         37        DO_ICALL                                         $20     
         38        ADD                                              ~21     $20, 1
         39        ASSIGN                                                   !4, ~21
   23    40        INIT_FCALL                                               'substr'
         41        SEND_VAR                                                 !3
         42        INIT_FCALL                                               'strpos'
         43        SEND_VAR                                                 !3
         44        SEND_VAL                                                 '%3C'
         45        DO_ICALL                                         $24     
         46        ADD                                              ~25     $24, 1
         47        SEND_VAL                                                 ~25
         48        INIT_FCALL                                               'strpos'
         49        SEND_VAR                                                 !3
         50        SEND_VAL                                                 '%3E'
         51        DO_ICALL                                         $26     
         52        SUB                                              ~27     $26, !4
         53        SEND_VAL                                                 ~27
         54        DO_ICALL                                         $28     
         55        INIT_FCALL                                               'trim'
         56        INIT_FCALL                                               'strip_tags'
         57        SEND_VAR                                                 !3
         58        DO_ICALL                                         $30     
         59        SEND_VAR                                                 $30
         60        DO_ICALL                                         $31     
         61        FETCH_DIM_W                                      $23     !2, !5
         62        ASSIGN_DIM                                               $23, $28
         63        OP_DATA                                                  $31
   17    64    > > JMP                                                      ->8
         65    >   FE_FREE                                                  $10
   27    66        INIT_FCALL                                               'var_dump'
         67        SEND_VAR                                                 !2
         68        DO_ICALL                                                 
         69      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.35 ms | 1400 KiB | 25 Q