Jump to content

Sorting a multidimensional array by certain key


pocobueno1388

Recommended Posts

I am having issues sorting an array that come from a SimpleXMLElement Object.

 

 

The array looks like this:

SimpleXMLElement Object
(
    [www] => SimpleXMLElement Object
        (

[allen] => SimpleXMLElement Object
        (
            [city] => Allen
            [area] => Allen
            [county] => Collin
            [state] => Texas
                (
                )

            [newcontent] => text content
        )

    [addison] => SimpleXMLElement Object
        (
            [city] => Addison
            [area] => Addison
            [county] => Dallas
            [state] => Texas
                (
                )

            [newcontent] => text content
        )

    [amarillo] => SimpleXMLElement Object
        (
            [city] => Amarillo
            [area] => Amarillo
            [county] => Potter
            [state] => Texas
                (
                )
        )
)

 

I want to sort it by city in alphabetical order. This array is being populated from an XML file. I know you can make a XSLT template to sort an XML file, but I can't figure out how to do that. If anyone could help, it would be greatly appreciated. Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.