<?php $html = "<div>this outer <a href='#'>first link</a> is the best <span>destination</span></div><a href='#'>second link</a>"; $doc = new DOMDocument(); $doc->loadHTML($html); $links = $doc->getElementsByTagName('a'); foreach($links as $link) { echo $doc->saveHTML($link) . PHP_EOL; }
You have javascript disabled. You will not be able to edit any code.