PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.
Hello
I have some xml (a sitemap). I pass this into my php code and use the current server url to find the relevant record within the sitemap. I then want to use the array made from the sitemap to find what the next record in the sitemap is and use this for a next link on my page.
<?php
$domain = $_SERVER['HTTP_HOST'];
$path = $_SERVER['SCRIPT_NAME'];
$currenturl = "http://" . $domain . $path;
include 'sitemap.php';
$xml = new SimpleXMLElement($xmlstr);
foreach ($xml->url as $url) {
if ((string) $url->loc == $currenturl) {
//TO DO: Go to the next record in the sitemap/array , get this url and set it to = &nexturl
echo
'<div class="navigation-div"><ul class="navigation"><li class="next">
<a href="', &nexturl ,'">NEXT</a></li>
</li></ul></div>';
}
}
?>
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.