$_POST Array from html form

前端 未结 4 711
悲&欢浪女
悲&欢浪女 2020-11-28 12:46

I am trying to send data from multiple checkboxes (id[]) and create an array \"info\" in php to allow me to run a script for each value (however the quantity of values may c

4条回答
  •  死守一世寂寞
    2020-11-28 13:16

    I don't know if I understand your question, but maybe:

    foreach ($_POST as $id=>$value)
        if (strncmp($id,'id[',3) $info[rtrim(ltrim($id,'id['),']')]=$_POST[$id];
    

    would help

    That is if you really want to have a different name (id[key]) on each checkbox of the html form (not very efficient). If not you can just name them all the same, i.e. 'id' and iterate on the (selected) values of the array, like: foreach ($_POST['id'] as $key=>$value)...

提交回复
热议问题