Foreach value from POST from form

前端 未结 4 1233
野性不改
野性不改 2020-12-01 23:32

I post some data over to another page from a form. It\'s a shopping cart, and the form that\'s being submitted is being generated on the page before depending on how many it

4条回答
  •  误落风尘
    2020-12-01 23:57

    i wouldn't do it this way

    I'd use name arrays in the form elements

    so i'd get the layout

    $_POST['field'][0]['name'] = 'value';
    $_POST['field'][0]['price'] = 'value';
    $_POST['field'][1]['name'] = 'value';
    $_POST['field'][1]['price'] = 'value';
    

    then you could do an array slice to get the amount you need

提交回复
热议问题