Skip to content

Instantly share code, notes, and snippets.

@flesch
Created August 18, 2012 14:49
Show Gist options
  • Save flesch/3387199 to your computer and use it in GitHub Desktop.
Save flesch/3387199 to your computer and use it in GitHub Desktop.
document::getElementsByClassName("")
<?php
class document {
public static function getElementsByClassName($name) {
global $xpath;
$nodes = array();
$elements = $xpath->query(sprintf("//div[contains(@class, '%s')]", $name));
foreach ($elements as $e) {
array_push($nodes, $e);
}
return $nodes;
}
}
?>
@toutcourtc
Copy link

Thanks a lot !
Still usefull eleven years later !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment