3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html_string = '<!DOCTYPE html> <html> <body> <div id="foo"> This is a paragraph with <strong>Some nested tags</strong> </div> <div class="test" id="bar"> <div> And a nested div? </div> </div> <div class="baz test"> <p> Pretty normal HTML. </p> </div> </body> </html>'; $regex = '/<div[^>]*?(class="(.+?)"[^>]*)?>((?:.*?(?:(?!<div)|(?R))*)*)' . '<\/div>/sm'; if (preg_match_all($regex, $html_string, $matches, PREG_SET_ORDER)) { var_dump($matches); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/nmAe9
function name:  (null)
number of ops:  13
compiled vars:  !0 = $html_string, !1 = $regex, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%21DOCTYPE+html%3E%0A%3Chtml%3E%0A%09%3Cbody%3E%0A%09%09%3Cdiv+id%3D%22foo%22%3E%0A%09%09%09This+is+a+paragraph+with%0A%09%09%09%3Cstrong%3ESome+nested+tags%3C%2Fstrong%3E%0A%09%09%3C%2Fdiv%3E%0A%0A%09%09%3Cdiv+class%3D%22test%22+id%3D%22bar%22%3E%0A%09%09%09%3Cdiv%3E%0A%09%09%09%09And+a+nested+div%3F%0A%09%09%09%3C%2Fdiv%3E%0A%09%09%3C%2Fdiv%3E%0A%0A%09%09%3Cdiv+class%3D%22baz+test%22%3E%0A%09%09%09%3Cp%3E%0A%09%09%09%09Pretty+normal+HTML.%0A%09%09%09%3C%2Fp%3E%0A%09%09%3C%2Fdiv%3E%0A%09%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   25     1        ASSIGN                                                   !1, '%2F%3Cdiv%5B%5E%3E%5D%2A%3F%28class%3D%22%28.%2B%3F%29%22%5B%5E%3E%5D%2A%29%3F%3E%28%28%3F%3A.%2A%3F%28%3F%3A%28%3F%21%3Cdiv%29%7C%28%3FR%29%29%2A%29%2A%29%3C%5C%2Fdiv%3E%2Fsm'
   28     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        SEND_VAL                                                 2
          7        DO_ICALL                                         $5      
          8      > JMPZ                                                     $5, ->12
   29     9    >   INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
   30    12    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.68 ms | 1395 KiB | 17 Q