按日期排序多维数组,但只有它的子项

i'm trying to sort the children of an array but failing miserably.. Problem is that only the children should get sorted/compared against another by their ['date']['form_date '] value, not the first layer of the array :(

  Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-07-07
                            [to_date] => 2018-07-07
                        )

                    [post] => Special: Pferdefotografie
                )

            [1] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-07-21
                            [to_date] => 2018-07-21
                        )

                    [post] => Fotoexkursion Südafrika
                )

            [2] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-07-21
                            [to_date] => 2018-07-21
                        )

                    [post] => Fotoexkursion Landschaftsfotografie
                )

            [3] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-07-21
                            [to_date] => 2018-07-21
                        )

                    [post] => Bildaufbau und Komposition
                )

            [4] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-07-22
                            [to_date] => 2018-07-22
                        )

                    [post] => Bildaufbau und Komposition
                )

        )

    [1] => Array
        (
            [0] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-08-11
                            [to_date] => 2018-08-11
                        )

                    [post] => Bildaufbau und Komposition
                )

            [1] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-08-04
                            [to_date] => 2018-08-04
                        )

                    [post] => Makrofotografie 1
                )

            [2] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-08-26
                            [to_date] => 2018-08-26
                        )

                    [post] => Tierfotografie 2
                )

            [3] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-08-19
                            [to_date] => 2018-08-19
                        )

                    [post] => Tierfotografie 1
                )

        )

    [2] => Array
        (
            [0] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-09-15
                            [to_date] => 2018-09-15
                        )

                    [post] => Bildaufbau und Komposition
                )

            [1] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-09-02
                            [to_date] => 2018-09-02
                        )

                    [post] => Makrofotografie 2
                )

            [2] => Array
                (
                    [date] => Array
                        (
                            [from_date] => 2018-09-01
                            [to_date] => 2018-09-01
                        )

                    [post] => Makrofotografie 1
                )

        )

)

I tried on using usort for comparing the dates, but i guess it fails because of the level of nesting!?

usort($events, function ($a, $b) {
    return strtotime($a[0]['date']['from_date']) - strtotime($b[0]['date']['from_date']);
});

Any help is much appreciated! Thanks in advance for looking into this :)

Because your dates are in Y-m-d format, you don't need to bother converting them to timestamps -- just compare them as strings. As deceze said, you just need to iterate the first level and remember to modify by reference (so that you aren't modifying a "copy" of the array).

Code: (Demo: https://3v4l.org/AXsqR )

foreach ($array as &$set) {
    usort($set, function ($a, $b) {
        return strcmp($a['date']['from_date'], $b['date']['from_date']);
    });
}