homepage Welcome to WebmasterWorld Guest from 54.81.170.186
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
PHP: How to Sort an Array Through Loop
PHP: How to Sort an Array
chamara




msg:3725442
 11:34 am on Aug 18, 2008 (gmt 0)

Hello.
I am working on a web page that lists some property stored in an XML
file and I'm having trouble with figuring out how to sort the listings by their "price" element. Currently I pull the "property" elements from the XML into an array and print out the HTML list of property in a non-sorted manner.
I'd like it to print out with a acceding oder for the price followed by a list of property in that price. I'm not sure how to code it though. Any help would be
appreciated. Below is a snippet from the XML file:

<?xml version="1.0" encoding="iso-8859-1" ?>
<ToLet>
<Property>
<Refnumber>21.00</Refnumber>
<Number>34</Number>
<Street>Clifton Road</Street>
<Address3>Newbury Park</Address3>
<Address4>Essex</Address4>
<price>1234</price>
</Property>

<Property>
<Refnumber>22.00</Refnumber>
<Number>54</Number>
<Street>Clifton Road</Street>
<Address3>Newbury Park</Address3>
<Address4>Essex</Address4>
<price>345</price>
</Property>
</ToLet>

 

cmarshall




msg:3725454
 12:06 pm on Aug 18, 2008 (gmt 0)

Hi chamara, and welcome to WebmasterWorld!

I suspect that you would be helped by asking this in the PHP Forum [webmasterworld.com], as well as this one.

You can use the PHP SimpleXML [us2.php.net] or the PHP DOMXML [us2.php.net] support to parse and sort the XML, but the printing will probably done through good old-fashioned PHP routines.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved