如何使用POST方法从数组中获取值

时间:2021-09-04 19:14:20

How to get value in another page using the POST method?

如何使用POST方法在另一个页面中获取值?

<label>
    <input type="radio" value = "1" name="jsq[1]" checked>1
</label>
<label>
    <input type="radio" value = "2" name="jsq[1]">2
</label></br>
<label>
    <input type="radio" value = "3" name="jsq[1]">3
</label>
<label>
    <input type="radio" value = "4" name="jsq[1]">4
</label></br>
<label>
    <input type="radio" value = "5" name="jsq[1]">5
</label>

I want to get value of jsq[1] in myarr[1]. How can I do that?

我想在myarr [1]中获得jsq [1]的值。我怎样才能做到这一点?

$myarr[1] = $_POST['jsq[1]'];

1 个解决方案

#1


Without going into the question why you're naming them jsq[1] an not just jsq...

没有问题为什么你要命名为jsq [1]而不仅仅是jsq ......

you're almost there, but it should be

你几乎就在那里,但它应该是

$myarr[1] = $_POST['jsq'][1];

It's by the way always a good idea to check this king of things using print_r($_POST); or var_dump($_POST);

顺便说一句,使用print_r($ _ POST)检查这个东西总是一个好主意;或var_dump($ _ POST);

#1


Without going into the question why you're naming them jsq[1] an not just jsq...

没有问题为什么你要命名为jsq [1]而不仅仅是jsq ......

you're almost there, but it should be

你几乎就在那里,但它应该是

$myarr[1] = $_POST['jsq'][1];

It's by the way always a good idea to check this king of things using print_r($_POST); or var_dump($_POST);

顺便说一句,使用print_r($ _ POST)检查这个东西总是一个好主意;或var_dump($ _ POST);