Jump to content

[SOLVED] Sorting an array


keeps21

Recommended Posts

I have an array which I want to sort by the index 'pubDate' from most recent to oldest

 

But I'm not sure how to do it.

 

Here is the array I'm working with

 

Array
(
    [0] => Array
        (
            [title] => SimpleXMLElement Object
                (
                    [0] => Warriors net two more signings
                )

            [pubDate] => SimpleXMLElement Object
                (
                    [0] => Mon, 08 Jun 2009 10:10:15 GMT
                )

            [description] => SimpleXMLElement Object
                (
                )

            [link] => SimpleXMLElement Object
                (
                    [0] => http://www.whitleywarriors.net/news/view/id/202/warriors-net-two-more-signings.html
                )

        )

    [1] => Array
        (
            [title] => SimpleXMLElement Object
                (
                    [0] => New Website Launched
                )

            [pubDate] => SimpleXMLElement Object
                (
                    [0] => Mon, 01 Jun 2009 11:16:50 GMT
                )

            [description] => SimpleXMLElement Object
                (
                )

            [link] => SimpleXMLElement Object
                (
                    [0] => http://www.whitleywarriors.net/news/view/id/200/new-website-launched.html
                )

        )

    [2] => Array
        (
            [title] => SimpleXMLElement Object
                (
                    [0] => Warrior Spike
                )

            [pubDate] => SimpleXMLElement Object
                (
                    [0] => Wed, 27 May 2009 22:17:08 GMT
                )

            [description] => SimpleXMLElement Object
                (
                )

            [link] => SimpleXMLElement Object
                (
                    [0] => http://www.whitleywarriors.net/news/view/id/199/warrior-spike.html
                )

        )

    [3] => Array
        (
            [title] => SimpleXMLElement Object
                (
                    [0] => Legends return to the ice
                )

            [pubDate] => SimpleXMLElement Object
                (
                    [0] => Wed, 27 May 2009 22:16:15 GMT
                )

            [description] => SimpleXMLElement Object
                (
                )

            [link] => SimpleXMLElement Object
                (
                    [0] => http://www.whitleywarriors.net/news/view/id/198/legends-return-to-the-ice.html
                )

        )

    [4] => Array
        (
            [title] => SimpleXMLElement Object
                (
                    [0] => Captain Dunn - Sample and Wilson to return
                )

            [pubDate] => SimpleXMLElement Object
                (
                    [0] => Thu, 21 May 2009 10:46:56 GMT
                )

            [description] => SimpleXMLElement Object
                (
                )

            [link] => SimpleXMLElement Object
                (
                    [0] => http://www.whitleywarriors.net/news/view/id/192/captain-dunn--sample-and-wilson-to-return.html
                )

        )

    [5] => Array
        (
            [title] => SimpleXMLElement Object
                (
                    [0] => Two in, one out
                )

            [pubDate] => SimpleXMLElement Object
                (
                    [0] => Sat, 16 May 2009 14:05:23 GMT
                )

            [description] => SimpleXMLElement Object
                (
                )

            [link] => SimpleXMLElement Object
                (
                    [0] => http://www.whitleywarriors.net/news/view/id/180/two-in-one-out.html
                )

        )
)

 

How would I do this?

Link to comment
https://forums.phpfreaks.com/topic/161394-solved-sorting-an-array/
Share on other sites

I don't think so. What I'm wanting to do is merge a number of feeds together, and output the latest x items ordered by date, most recent first.

 

I'll be taking a feed, reading the feed data into the array, and then repeating for a number of feeds.

 

I then want to sort the order of the array.

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.