如何使用POST方法从数组中获取值 [英] How to get values from array using POST method

查看:548
本文介绍了如何使用POST方法从数组中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我想获得 jsq [1] myarr [1] 中。我怎么能这样做?

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


解决方案

jsq [1]不只是jsq ...

你几乎在那里,但应该是

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

使用print_r($ _ POST)检查这些事情的方法总是一个好主意;或var_dump($ _ POST);


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

<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] = $_POST['jsq[1]'];

解决方案

Without going into the question why you're naming them jsq[1] an not just 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);

这篇关于如何使用POST方法从数组中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆