Jump to content

Deep Array Sorting


StevenAFC

Recommended Posts

Hi All,

 

I have a fairly deep array sort I am struggling to get working. Basically, I have a list of topics, which are associated to a message, these messages have a posting time. I would like to sort the topics by the most recent message posting time. I have everything loaded into a single array which looks like this :

 

Array
(
    [Category] => Array
        (
            [id] => 1
            [name] => General
            [forum_id] => 1
            [description] => Feel free to chat about whatever you want
        )

    [Topic] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [sticky] => 0
                    [locked] => 0
                    [message_id] => 1
                    [category_id] => 1
                    [last_post_id] => 2
                    [Message] => Array
                        (
                            [0] => Array
                                (
                                    [id] => 1
                                    [topic_id] => 1
                                    [user_id] => 3
                                    [time] => 2009-03-23 01:07:15
                                    [subject] => First Forum
                                    [body] => This is the body of my first post
                                    [modified] => 2009-03-23 01:07:15
                                    [user] => Array
                                        (
                                            [id] => 3
                                            [username] => BlackICE
                                        )

                                )

                            [1] => Array
                                (
                                    [id] => 2
                                    [topic_id] => 1
                                    [user_id] => 2
                                    [time] => 2009-03-23 01:08:15
                                    [subject] => First Forum
                                    [body] => I dont know how you make such genius posts
                                    [modified] => 2009-03-23 01:07:15
                                    [user] => Array
                                        (
                                            [id] => 2
                                            [username] => Chk1
                                        )

                                )

                        )

                )

            [1] => Array
                (
                    [id] => 3
                    [sticky] => 0
                    [locked] => 0
                    [message_id] => 4
                    [category_id] => 1
                    [last_post_id] => 4
                    [Message] => Array
                        (
                            [0] => Array
                                (
                                    [id] => 4
                                    [topic_id] => 3
                                    [user_id] => 2
                                    [time] => 2009-03-23 01:10:15
                                    [subject] => Another Heading
                                    [body] => Another post
                                    [modified] => 2009-03-23 01:08:15
                                    [user] => Array
                                        (
                                            [id] => 2
                                            [username] => Chk1
                                        )

                                )

                        )

                )

        )

)

 

Link to comment
https://forums.phpfreaks.com/topic/151093-deep-array-sorting/
Share on other sites

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.