<?php
$contents = file_get_contents('link here');
$doc = new DOMDocument();
@$doc->loadHTML($contents);
$xpath = new DOMXPath($doc);
$xquery = '//tr[td[a]]';
$links = $xpath->query($xquery);
foreach ($links as $el) {
$string = ($doc->saveHTML($el));
preg_match('/<a class="LN" href=".*" onclick=".*">(.*)<\/a>/i', $string, $name);
preg_match('/<td align="center">.*\s*<\/td>\s*<td>(.*)<\/td>/i', $string, $locations);
echo strip_tags($name[1]).' '.strip_tags($locations[1]);
}
?>
我的 $string 的价值是
<tr>
<td>
1.
</td>
<td>
<a class="LN" href="" onclick="">
<b>Aaberg, Aaron E</b></a>
</td>
<td align="center">
54
</td>
<td><a href="">Anchorage, AK</a><br />
<a href="">Nondalton, AK</a><br />
</td>
<td> </td><td><a href="">
View Details
</a></td></tr>
为什么我无法获得我的 $location[i]?