Na demotach (itp. stronach) kod z obrazkiem i źródłem wygląda mniej więcej tak
<!-- jeśli jest źródło -->
Więc, jak powinienem zrobić, żeby mieć dopasowane źródła do obrazków?
Proszę o pomoc, kompletnie nie mam pomysłu...
<!-- jeśli jest źródło -->
<pre> <?php // Dokument HTML libxml_use_internal_errors( true ); $doc = new DOMDocument(); $doc->loadHTML( $source ); // Szukamy wszystkich <div class="demot_pic"> $xpath = new DOMXPath( $doc ); $pictures = $xpath->query( "//div[@class='demot_pic']" ); foreach( $pictures as $picture ) { $demot["url"] = $picture->getElementsByTagName( "a" )->item( 0 )->getAttribute( "href" ); $demot["img"] = $picture->getElementsByTagName( "img" )->item( 0 )->getAttribute( "src" ); // Przechodzimy w dół dokumentu HTML szukając sąsiada <div class="demot_pic"> $source = $picture->nextSibling; while( $source != null ) { if( $source instanceof DOMElement ) { // Znaleźliśmy sąsiada! Sprawdzamy czy to <div class="source"> if( $source->nodeName == "div" && $source->getAttribute( "class" ) == "source" ) { $demot["source"] = $source->textContent; } break; } $source = $source->nextSibling; } $demoty[] = $demot; } ?> </pre>