How can I use the array-format input field names in my HTML form that posts to PHP?

前端 未结 1 1699
醉酒成梦
醉酒成梦 2020-12-10 15:51

I understand the basics of using the array-formatted HTML input names. If I had a form with a variable number of \'item\' inputs I might do something like this for each of

相关标签:
1条回答
  • 2020-12-10 16:06

    It's not possible to do what you want, but if it helps, here's some code to piece it back together that I think will work (with item_name[] and item_description[]):

    $items_desc = $_POST["item_description"];
    $items_name = $_POST["item_name"];
    $items = array();
    for ($i = 0; $i < count($items_name); $i++)
    {
        $items[] = array("name" => $items_name[$i], "description" => $items_desc[$i]);
    }
    
    0 讨论(0)
提交回复
热议问题