- parse_str: documentation ( source)
- explode: documentation ( source)
<?php
$html = <<<HTML
<a class="profile-link" href="CompanyProfile.aspx?PID=4813&country=211&practicearea=0&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..
}
}