drz5553 2015-06-29 19:23
浏览 21

在多维数组中发布多维数组

We need to post products here.

The product will have more than one color, while each color have different image.

I have created a form. in this form when user click add more color, it will create them a block div to pick up multiple images for that color, and so on for the next color.

Here is the sketch or input that I will create dynamically with js

//here is the master data
<input type="text" name="name"/>

//follows are the mapping data

<input type="text" name="color[red]" value="red" /> 
    <input type="file" name="color[red][image1]" /> 
    <input type="file" name="color[red][image2]" /> 
    <input type="file" name="color[red][image3]" /> 
    <input type="file" name="color[red][image4]" /> 

<input type="text" name="color[blue]" value="blue" />
    <input type="file" name="color[blue][image1]" /> 
    <input type="file" name="color[blue][image2]" /> 
    <input type="file" name="color[blue][image3]" /> 
    <input type="file" name="color[blue][image4]" /> 


    And so on...

I need a help how to post the inputs above with php, so that the output array would be like this:

array (
    name => one
    color => array (
                [0] => array (
                        name =>red
                        image => array (
                                    [0] =>oneRed1.jpg
                                    [1] =>oneRed2.jpg
                                    [2] =>oneRed3.jpg
                                 )  
                        )

                [1] => array (
                        name =>blue
                        image => array (
                                    [0] =>oneBlue1.jpg
                                    [1] =>oneBlue2.jpg
                                    [2] =>oneBlue3.jpg
                                 )  
                            )   
                [2] => array (
                        name =>purple
                        image => array (
                                    [0] =>onePurple1.jpg
                                    [1] =>onePurple2.jpg
                                    [2] =>onePurple3.jpg
                                 )  
                        )   
            )
    )

Thank you very much in advance for any help.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看