Multiple inputs with same name through POST in php

后端 未结 5 2131
误落风尘
误落风尘 2020-11-22 02:54

Is it possible to get multiple inputs of the same name to post and then access them from PHP? The idea is this: I have a form that allows the entry of an indefinite number

5条回答
  •  旧时难觅i
    2020-11-22 03:13

    Change the names of your inputs:

    
    
    
    
    
    

    Then:

    $_POST['xyz'][0] == 'Lorem'
    $_POST['xyz'][4] == 'amet'
    

    If so, that would make my life ten times easier, as I could send an indefinite amount of information through a form and get it processed by the server simply by looping through the array of items with the name "xyz".

    Note that this is probably the wrong solution. Obviously, it depends on the data you are sending.

提交回复
热议问题