Skip to content

Instantly share code, notes, and snippets.

@ss23
Created December 5, 2014 06:24
Show Gist options
  • Save ss23/2c50ee7135571822a26c to your computer and use it in GitHub Desktop.
Save ss23/2c50ee7135571822a26c to your computer and use it in GitHub Desktop.
foreach ($dommy as $info) {
if ($first) {
// These are <th>'s providing information about the nations
foreach ($info->childNodes as $child) {
if ($first) {
$first = false; // Notice this is reused more than once, but a single var works fine
continue; // Skip first child, it's blank
}
if (get_class($child->firstChild) == 'DOMText') {
$cities[] = array('Name' => $child->textContent);
} else {
$cities[] = array('Name' => $child->textContent, 'URL' => $child->firstChild->getAttribute('href'));
}
}
continue;
}
// We're not on the first, so real data is here now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment