Last active
April 12, 2017 16:25
-
-
Save miklb/2dff5a40a88c8d76e43b9d4e8771429c to your computer and use it in GitHub Desktop.
attempting to get last a tag and apply a class
This file contains 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
$dom = new DOMDocument; | |
$dom->loadHTML($embed_html, LIBXML_HTML_NOIMPLIED); | |
$nodelinks = $dom->getElementsByTagName('a'); | |
$links = iterator_to_array($nodelinks); | |
var_dump($links); | |
foreach ( $links as $link ) { | |
if (end($links)) { | |
$link->setAttribute("class","u-url"); | |
} | |
}; | |
$embed_html = $dom->saveHTML(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
give this a try: