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); var_dump($matches);
based on T7ajf
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(4) { [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(3) "div" [2]=> string(123) "<iframe width="1280" height="720" src="//www.youtube.com/embed/NKvxWMsGW9E?rel=0" frameborder="0" allowfullscreen></iframe>" [3]=> string(105) "width="1280" height="720" src="//www.youtube.com/embed/NKvxWMsGW9E?rel=0" frameborder="0" allowfullscreen" }