单数组中的多维数组

时间:2019-09-24 13:42:32

标签: php

我需要从单个数组循环中创建多维数组,该数组的值将与颜色大小的材质等类似,子级将为红色,橙色

EX:

Array
(
    [0] => Array
        (
            [option_value_id] => 46
            [option_id] => 11
            [image] => 
            [sort_order] => 2
            [language_id] => 1
            [name] => Size
            [type] => select
            [option_value_name] => Small
        )

    [1] => Array
        (
            [option_value_id] => 50
            [option_id] => 13
            [image] => 
            [sort_order] => 1
            [language_id] => 1
            [name] => color
            [type] => image
            [option_value_name] => Black
        )

    [2] => Array
        (
            [option_value_id] => 48
            [option_id] => 11
            [image] => 
            [sort_order] => 2
            [language_id] => 1
            [name] => Size
            [type] => select
            [option_value_name] => Large
        )

    [3] => Array
        (
            [option_value_id] => 50
            [option_id] => 13
            [image] => 
            [sort_order] => 1
            [language_id] => 1
            [name] => color
            [type] => image
            [option_value_name] => Black
        )

    [4] => Array
        (
            [option_value_id] => 47
            [option_id] => 11
            [image] => 
            [sort_order] => 2
            [language_id] => 1
            [name] => Size
            [type] => select
            [option_value_name] => Medium
        )

    [5] => Array
        (
            [option_value_id] => 50
            [option_id] => 13
            [image] => 
            [sort_order] => 1
            [language_id] => 1
            [name] => color
            [type] => image
            [option_value_name] => Black
        )

)

这是我需要用这种格式制作的数组

Array
(
    [0] => Array
        (
            [product_option_value] => Array
                (
                    [0] => Array
                        (
                            [option_value_id] => 50
                            [name] => Black
                        )
                )

            [option_id] => 13
            [name] => color
            [type] => image
        )

    [1] => Array
        (
            [product_option_value] => Array
                (
                    [0] => Array
                        (
                            [option_value_id] => 46
                            [name] => Small
                        )

                    [1] => Array
                        (
                            [option_value_id] => 47
                            [name] => Medium
                        )

                    [2] => Array
                        (
                            [option_value_id] => 48
                            [name] => Large

                        )

                )

            [option_id] => 11
            [name] => Size
            [type] => select
        )

)

0 个答案:

没有答案