Skip to content

Instantly share code, notes, and snippets.

@huglester
Created February 1, 2013 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huglester/4694477 to your computer and use it in GitHub Desktop.
Save huglester/4694477 to your computer and use it in GitHub Desktop.
$url = "http://factoryjoe.com/projects/emoticons/";
$html = file_get_contents($url);
$doc = new DOMDocument();
$doc->strictErrorChecking = FALSE;
$doc->loadHTML($html);
$xml = simplexml_import_dom($doc);
$flags = array();
foreach ($xml->body->div->div->table[1]->tbody->tr as $value)
{
$flag['name'] = (string)$value->td[1];
$flag['equivalents'] = (string)$value->td[2]->span;
$flags[] = $flag;
}
$smiles = array();
foreach ($xml->body->div->div->table->tbody->tr as $value)
{
$smile = array();
$smile['name'] = (string)$value->td[2];
$smile['slug'] = (string)$value->td[0]->span['class'];
$smile['src'] = (string)$value->td[1]->img['src'];
$smile['style'] = (string)$value->td[1]->img['style'];
foreach ($value->td[3]->span as $value) {
$smile['equivalents'][] = (string)$value;
}
$smiles[] = $smile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment