- parse_str: documentation ( source)
- var_export: documentation ( source)
- parse_url: documentation ( source)
<?php
$html = <<<HTML
<li style="opacity: 1;">
<a class="profile-link" href="CompanyProfile.aspx?PID=4813&country=211&practicearea=0&pagenum=" title="1-844-Iran-Law">Amin Alemohammad</a>
<!--<a class="profile-link" href="javascript:void(0)" title="1-844-Iran-Law">Amin Alemohammad</a>-->
<img src="/Images/Uploaded/Photos/4813_1844IranLaw.png" style="max-width:140px; max-height:140px">
<div class="results-profile">
<h2>Amin Alemohammad</h2>
<p><strong>Firm:</strong> 1-844-Iran-Law <br> <strong>Country:</strong> USA</p>
<p class="blue"><strong>Practice Area:</strong> Iranian Desk</p>
<ul>
<li class="tel-icon" style="opacity: 1;">Tel: +1-202-465-8692</li>
<li class="fax-icon" style="opacity: 1;">Fax: +1-202-776-0136</li>
<li class="email-icon">Email: <a style="position:relative; z-index:9999;" href="mailto:amin@1844iranlaw.com">amin@1844iranlaw.com</a></li>
</ul>
</div><!-- results profile -->
<img class="practice-logo" src="/Images/Uploaded/Logos/4813_1844IranLaw.png" style="max-width:185px; max-height:70px;">
<a class="results-btn contact-btn" href="CompanyProfile.aspx?PID=4813&country=211&practicearea=0&pagenum=" title="View Full Profile">VIEW FULL PROFILE</a>
<!--<a class="results-btn contact-btn" href="CompanyProfile.aspx?PID=4813&country=211&practicearea=0&pagenum=" title="1-844-Iran-Law">CONTACT</a>-->
<a class="results-btn website-btn" href="http://www.1844iranlaw.com" title="www.1844iranlaw.com">VIEW WEBSITE</a>
</li>
HTML;
$dom=new DOMDocument;
//libxml_use_internal_errors(true); // for <li> warning suppress
$dom->loadHTML($html);
//libxml_clear_errors(); // for <li> warning suppress
$xpath = new DOMXPath($dom);
foreach ($xpath->evaluate("//a[@class='profile-link']") as $node) {
parse_str(parse_url($node->getAttribute('href'), PHP_URL_QUERY), $output);
$output['title'] = $node->getAttribute('title');
$output['text'] = $node->nodeValue;
}
var_export($output);