3v4l.org

run code in 300+ PHP versions simultaneously
<?php $content = 'foo bar baz <img src="http://ak-hdl.buzzfed.com/static/2014-06/6/12/enhanced/webdr08/enhanced-21313-1402070821-11.jpg" width="500" height="1000"/> dragons and ponies.'; for ( $i = 0; $i < 1000; $i++ ) { if ( preg_match_all( '#<(?P<tag>img)[^<]*?(?:>[\s\S]*?<\/(?P=tag)>|\s*\/>)#', $content, $matches ) ) { foreach ( $matches[0] as $match ) { preg_match( '/ src="([^"]+)"/', $content, $src ); preg_match( '/ width="([0-9]+)"/', $content, $width ); preg_match( '/ height="([0-9]+)"/', $content, $height ); } } }

preferences:
79.13 ms | 405 KiB | 5 Q