jumasol Posted October 2, 2013 Share Posted October 2, 2013 Hi. I am intended upon getting some css style in the head of my site when certain links are published in a given URL in it (namely the sitemap xml of the site). So far, I have reached this point to create an array to list the URLs in the page: <?php $urls = array(); $DomDocument = new DOMDocument(); $DomDocument->preserveWhiteSpace = false; $DomDocument->load('http://www. sitio .com/index.php?option=com_xmap&view=xml&tmpl=component&id=1'); $DomNodeList = $DomDocument->getElementsByTagName('loc'); foreach($DomNodeList as $url) { $urls[] = $url->nodeValue; } //display it echo "<pre>"; print_r($urls); echo "</pre>"; ?> Which displays this array precisely: Array ( [0] => http://www. sitio .com/enlace-a [1] => http://www. sitio .com/enlace-b [2] => http://www. sitio .com/enlace-c [3] => http://www. sitio .com/enlace-d [4] => http://www. sitio .com/enlace-e [5] => http://www. sitio .com/enlace-f [6] => http://www. sitio .com/enlace-g [7] => http://www. sitio .com/enlace-h [8] => http://www. sitio .com/enlace-i ) The question now is how to get any of them (for instance "enlace-b") in some conditional script to insert the css file. I would really appreciate some help. Best regards. Link to comment https://forums.phpfreaks.com/topic/282654-selecting-elements-from-array/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.