3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $_content = '<div><div><iframe width="1280" height="720" src="//www.youtube.com/embed/NKvxWMsGW9E?rel=0" frameborder="0" allowfullscreen></iframe></div></div><div>this div is ok</div>'; preg_match('#(?:<(?:div|span)[^>]*>[\s]*)*(<iframe[\s]*(?:[^>]+)>[\s]*<\/iframe[^>]*>)(?:[\s]*<(?:embed|script)[^>]*>[^<]*<\/(?:embed|script)[^>]*>[\s]*)*(?:<\/(?:div|span)[^>]*>)*#iu', $_content, $matches); //echo $_content; var_dump($matches);
based on 8XkdP
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { [0]=> string(145) "<div><div><iframe width="1280" height="720" src="//www.youtube.com/embed/NKvxWMsGW9E?rel=0" frameborder="0" allowfullscreen></iframe></div></div>" [1]=> string(123) "<iframe width="1280" height="720" src="//www.youtube.com/embed/NKvxWMsGW9E?rel=0" frameborder="0" allowfullscreen></iframe>" }