发布具有相同名称的多维输入数据

时间:2019-07-20 05:13:37

标签: php html input

我只是想上传一些具有 thumbnail thumbnail size thumbnail Hd thumbnail Hd size 的产品图片

缩略图缩略图尺寸缩略图高清 缩略图高清尺寸),此洞认为将构成一个单个产品图片,我可以上传多个图片。这就是为什么我使用以下标记(例如 )。

<tr>
    <td>Thumbnail<input type="text" name="images[single_image][thumbnail][]" id=""></td>
    <td>Thumbnail Size<input type="text" name="images[single_image][thumbnail_size][]" id=""></td>
    <td>Thumbnail Hd<input type="text" name="images[single_image][Thumbnail_hd][]" id=""></td>
    <td>Thumbnail Hd Size<input type="text" name="images[single_image][thumbnail_hd_size][]" id=""></td>
</tr>

<tr>
    <td>Thumbnail<input type="text" name="images[single_image][thumbnail][]" id=""></td>
    <td>Thumbnail Size<input type="text" name="images[single_image][thumbnail_size][]" id=""></td>
    <td>Thumbnail Hd<input type="text" name="images[single_image][Thumbnail_hd][]" id=""></td>
    <td>Thumbnail Hd Size<input type="text" name="images[single_image][thumbnail_hd_size][]" id=""></td>
</tr>

在php中发布数据后,我得到如下的 images 数组

"images" => array:1 [▼
    "single_image" => array:4 [▼
      "thumbnail" => array:2 [▼
        0 => "Thumbnail One"
        1 => "Thumbnail Two"
      ]
      "thumbnail_size" => array:2 [▼
        0 => "Thumbnail One Size"
        1 => "Thumbnail Two Size"
      ]
      "Thumbnail_hd" => array:2 [▼
        0 => "Thumbnail One Hd"
        1 => "Thumbnail Two Hd"
      ]
      "thumbnail_hd_size" => array:2 [▼
        0 => "Thumbnail One Hd size"
        1 => "Thumbnail Two Hd size"
      ]
    ]
  ]

但是我不想要,我想要的是 images 数组下面的内容,因为( thumbnail thumbnail size thumbnail Hd thumbnail Hd size ),它们是彼此属于的。

$images = [
    "single_image" => [
        "thumbnail" => "Thumbnail One",
        "thumbnail_size" => "Thumbnail One Size",
        "thumbnail_hd" => "Thumbnail One Hd",
        "thumbnail_hd_size" => "Thumbnail One Hd",
        "thumbnail_hd_size" => "Thumbnail One Hd Size",
    ],
    "single_image" => [
        "thumbnail" => "Thumbnail Two",
        "thumbnail_size" => "Thumbnail Two Size",
        "thumbnail_hd" => "Thumbnail Two Hd",
        "thumbnail_hd_size" => "Thumbnail Two Hd",
        "thumbnail_hd_size" => "Thumbnail Two Hd Size",
    ]
]

现在如何在HTML中实现上述数组,或者在html中无法实现;我如何使用数组函数在PHP中实现

0 个答案:

没有答案