Welcome to WebmasterWorld Guest from

Forum Moderators: httpwebwitch

Message Too Old, No Replies

PHP: How to Sort an Array Through Loop

PHP: How to Sort an Array

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

New User

5+ Year Member

joined:Aug 18, 2008
votes: 0

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" ?>
<Street>Clifton Road</Street>
<Address3>Newbury Park</Address3>

<Street>Clifton Road</Street>
<Address3>Newbury Park</Address3>

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2005
posts: 1526
votes: 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.