如何按日期对多维数组排序

时间:2018-10-26 08:21:17

标签: php arrays sorting multidimensional-array

我有这个数组,我想按publishedAt日期对其进行排序。

Array
(
    [0] => Array
    (
        [kind] => youtube#searchListResponse
        [etag] => "XI7nbFXulYBIpL0ayR_gDh3eu1k/cgzpc8GiKaManjtoA1jLFqg7omM"
        [nextPageToken] => CAIQAA
        [regionCode] => DE
        [pageInfo] => Array
        (
            [totalResults] => 2437
            [resultsPerPage] => 2
        )
        [items] => Array
        (
            [0] => Array
            (
                [kind] => youtube#searchResult
                [etag] => "XI7nbFXulYBIpL0ayR_gDh3eu1k/QV3mJQgBF2vmL2YWTPEzg1p4dZw"
                [id] => Array
                (
                    [kind] => youtube#video
                    [videoId] => Zltbhz6Vbos
                )
                [snippet] => Array
                (
                    [publishedAt] => 2018-10-25T18:15:01.000Z
                    [channelId] => UCmi_wJgwV8hn9SYOgxkcSnA
                    [title] => enatv 25 10 2018 deltio ΤΑΚΗΣ ΣΥΛΕΟΥΝΗΣ
                    [description] => Τηλεόραση ΕΝΑ Κεντρικής Ελλάδας - Κεντρικό Δελτίο Ειδήσεων 25-10-2018 Παρακολουθήστε ζωντανά το δελτίο ειδήσεω...
                    [thumbnails] => Array
                    (
                        [default] => Array
                        (
                            [url] => https://i.ytimg.com/vi/Zltbhz6Vbos/default.jpg
                            [width] => 120
                            [height] => 90
                        )

                        [medium] => Array
                        (
                            [url] => https://i.ytimg.com/vi/Zltbhz6Vbos/mqdefault.jpg
                            [width] => 320
                            [height] => 180
                        )

                        [high] => Array
                        (
                            [url] => https://i.ytimg.com/vi/Zltbhz6Vbos/hqdefault.jpg
                            [width] => 480
                            [height] => 360
                        )
                    )
                    [channelTitle] => ena tv
                    [liveBroadcastContent] => none
                )
            )
            [1] => Array
            (
                [kind] => youtube#searchResult
                [etag] => "XI7nbFXulYBIpL0ayR_gDh3eu1k/qaAeaQtZNEPqRVuM7xq1xyioBmQ"
                [id] => Array
                (
                    [kind] => youtube#video
                    [videoId] => rUJCDvAWx7I
                )
                [snippet] => Array
                (
                    [publishedAt] => 2018-10-24T19:45:24.000Z
                    [channelId] => UCmi_wJgwV8hn9SYOgxkcSnA
                    [title] => enatv 24 10 2018 deltio ΛΟΥΚΑΣ ΥΠΕΡΗΦΑΝΟΣ
                    [description] => Τηλεόραση ΕΝΑ Κεντρικής Ελλάδας - Κεντρικό Δελτίο Ειδήσεων 24-10-2018 Παρακολουθήστε ζωντανά το δελτίο ειδήσεω...
                    [thumbnails] => Array
                    (
                        [default] => Array
                        (
                            [url] => https://i.ytimg.com/vi/rUJCDvAWx7I/default.jpg
                            [width] => 120
                            [height] => 90
                        )

                        [medium] => Array
                        (
                            [url] => https://i.ytimg.com/vi/rUJCDvAWx7I/mqdefault.jpg
                            [width] => 320
                            [height] => 180
                        )

                        [high] => Array
                        (
                            [url] => https://i.ytimg.com/vi/rUJCDvAWx7I/hqdefault.jpg
                            [width] => 480
                            [height] => 360
                        )
                    )
                    [channelTitle] => ena tv
                    [liveBroadcastContent] => none
                )
            )
        )
    )

我尝试使用strtotime,但是我很难正确排序。 有什么建议吗?

谢谢。

0 个答案:

没有答案