I have a page that has a default message unless you change it. So when there's only one record in the xml you will see the default...but it you add a record the page will display that.
So I want my page to only print the last record in the xml.
The xml
Code:<myusers> <messages> <id>1</id> <message>words words and more words</message> </messages> </myusers>I would thing this would print the last message only...but that's not what I'm getting.Code:<?php $file = 'myxml.xml'; $xml = simplexml_load_file($file); foreach($xml->children as messages) { $i = count ($xml->messages)-1; echo $messages[$i]->message; } ?>



Reply With Quote

Bookmarks