3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<a href="http://www.mydomain.com/galeria/thumbnails.php?album=774" target="_blank"><img alt="/" src="http://img255.imageshack.us/img00/000/000001.png" height="133" width="113"></a>'; $doc = new DOMDocument; $doc->loadHTML( $html); $results = array(); foreach( $doc->getElementsByTagName( 'a') as $a) { // If there are no children, continue on if( !$a->hasChildNodes()) continue; // Find the child <img> tag, if it exists foreach( $a->childNodes as $child) { if( $child->nodeType == XML_ELEMENT_NODE && $child->tagName == 'img') { // Now we have the <a> tag in $a and the <img> tag in $child // Get the information we need: parse_str( parse_url( $a->getAttribute('href'), PHP_URL_QUERY), $a_params); $results[] = array( $a_params['album'], $child->getAttribute('src')); } } } var_dump( $results);

preferences:
46.63 ms | 402 KiB | 5 Q