Первое задание

Было:

Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
    [4] => e
    [5] => f
    [6] => g
    [7] => h
)
				

Стало:

Array
(
    [h] => Array
        (
            [g] => Array
                (
                    [f] => Array
                        (
                            [e] => Array
                                (
                                    [d] => Array
                                        (
                                            [c] => Array
                                                (
                                                    [b] => Array
                                                        (
                                                            [a] => 
                                                        )

                                                )

                                        )

                                )

                        )

                )

        )

)
				

Второе задание

Первый массив

Было:

Array
(
    [parent.child.field] => 1
    [parent.child.field2] => 2
    [parent2.child.name] => test
    [parent2.child2.name] => test
    [parent2.child2.position] => 10
    [parent3.child3.position] => 10
)
				

Стало:

Array
(
    [parent] => Array
        (
            [child] => Array
                (
                    [field] => 1
                    [field2] => 2
                )

        )

    [parent2] => Array
        (
            [child] => Array
                (
                    [name] => test
                )

            [child2] => Array
                (
                    [name] => test
                    [position] => 10
                )

        )

    [parent3] => Array
        (
            [child3] => Array
                (
                    [position] => 10
                )

        )

)
				

Второй массив

Было:

Array
(
    [parent] => Array
        (
            [child] => Array
                (
                    [field] => 1
                    [field2] => 2
                )

        )

    [parent2] => Array
        (
            [child] => Array
                (
                    [name] => test
                )

            [child2] => Array
                (
                    [name] => test
                    [position] => 10
                )

        )

    [parent3] => Array
        (
            [child3] => Array
                (
                    [position] => 10
                )

        )

)
				

Стало:

Array
(
    [parent.child.field] => 1
    [parent.child.field2] => 2
    [parent2.child.name] => test
    [parent2.child2.name] => test
    [parent2.child2.position] => 10
    [parent3.child3.position] => 10
)