0

I have got a multidimensional array :

[everything_list] => Array
        (
            [follow] => Array
                (
                    [2] => Array
                        (
                            [username] => 3333
                            [username_image] => qykhgz4861sna14af6h6mpage_f4a.jpg
                            [follow_username] => 6666
                            [follow_image] => flw3utn9igiqh7dtt2o61ydf8_174.jpeg
                            [date] => 1329183703
                        )

                    [3] => Array
                        (
                            [username] => 3333
                            [username_image] => qykhgz4861sna14af6h6mpage_f4a.jpg
                            [follow_username] => 8888
                            [follow_image] => nsm5rixy14lexm9cy15wzyg9u_224.jpg
                            [date] => 1329168868
                        )

                    [4] => Array
                        (
                            [username] => 6666
                            [username_image] => flw3utn9igiqh7dtt2o61ydf8_174.jpeg
                            [follow_username] => 8888
                            [follow_image] => nsm5rixy14lexm9cy15wzyg9u_224.jpg
                            [date] => 1328221789
                        )

                    [5] => Array
                        (
                            [username] => 8888
                            [username_image] => nsm5rixy14lexm9cy15wzyg9u_224.jpg
                            [follow_username] => 6666
                            [follow_image] => flw3utn9igiqh7dtt2o61ydf8_174.jpeg
                            [date] => 1328219453
                        )

                    [6] => Array
                        (
                            [username] => 8888
                            [username_image] => nsm5rixy14lexm9cy15wzyg9u_224.jpg
                            [follow_username] => Kolxoznik1
                            [follow_image] => 
                            [date] => 1328218207
                        )

                    [7] => Array
                        (
                            [username] => 8888
                            [username_image] => nsm5rixy14lexm9cy15wzyg9u_224.jpg
                            [follow_username] => 3333
                            [follow_image] => qykhgz4861sna14af6h6mpage_f4a.jpg
                            [date] => 1328217742
                        )

                )

            [pictures] => Array
                (
                    [0] => Array
                        (
                            [user] => 8888
                            [user_image] => nsm5rixy14lexm9cy15wzyg9u_224.jpg
                            [image] => nsm5rixy14lexm9cy15wzyg9u_224.jpg
                            [image_id] => 5
                            [text] => 
                            [date] => 1329072315
                            [comments] => 2
                            [first_image_id] => 4
                        )

                    [1] => Array
                        (
                            [user] => 8888
                            [user_image] => nsm5rixy14lexm9cy15wzyg9u_224.jpg
                            [image] => 0j1kjjzdv3ez07a0ee4lnmjb7_163.jpeg
                            [image_id] => 4
                            [text] => 
                            [date] => 1328577934
                            [comments] => 0
                            [first_image_id] => 4
                        )

                )

I want to sort this array by date and get something like :

[follow] => Array
{
....
}
[pictures] => Array
{
....
}
[follow] => Array
{
....
}
1

2 Answers 2

2

Check this Sorting a multidimensional array hope it will help

Sign up to request clarification or add additional context in comments.

Comments

0

If i understand your problem correctly, something like this should do it

function orderByDate($a, $b)
{
    return $a['date'] < $b['date'];
}

$newArray = $array['everything_list']['follow'] + $array['everything_list']['pictures'];
usort($newArray, 'orderByDate');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.