Created
October 9, 2018 09:42
-
-
Save imanilchaudhari/e860e95da7fce1c7c460002c36e2c5fa to your computer and use it in GitHub Desktop.
DOMElement getElementsByClass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getElementsByClass(&$parentNode, $tagName, $className) | |
{ | |
$nodes = array(); | |
$childNodeList = $parentNode->getElementsByTagName($tagName); | |
for ($i = 0; $i < $childNodeList->length; $i++) { | |
$temp = $childNodeList->item($i); | |
if (stripos($temp->getAttribute('class'), $className) !== false) { | |
$nodes[]=$temp; | |
} | |
} | |
return $nodes; | |
} | |
// source https://stackoverflow.com/questions/6366351/getting-dom-elements-by-classname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment