3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <a class="profile-link" href="CompanyProfile.aspx?PID=4813&amp;country=211&amp;practicearea=0&amp;pagenum=" title="1-844-Iran-Law">Amin Alemohammad</a> HTML; $doc = new DOMDocument(); $doc->loadHTML($html); foreach($doc->getElementsByTagName('a') as $a) { if ($a->getAttribute('class') === 'profile-link') { $parts = explode('?', $a->getAttribute('href')); parse_str($parts[1], $output); echo 'Title: ' . $a->getAttribute('title') . '<br>'; echo 'Text: ' . $a->nodeValue . '<br>'; echo 'PID: ' . $output['PID']; // etc.. } }

preferences:
26.03 ms | 402 KiB | 5 Q