zoukankan      html  css  js  c++  java
  • php获取$_POST同名参数数组

     今天写php的时候发现$_POST["arr"]无法获取参数arr的数组,记录一下。

     例如有以下表单需要提交:

      <input type="checkbox" name="arr" value="" />

      <input type="checkbox" name="arr" value="" />

      <input type="checkbox" name="arr" value="" />

      <input type="checkbox" name="arr" value="" />

     使用$_POST["arr"]只能获得最后选择的复选框的值,要获得全部选中的复选框的值需要把表单修改成下面:

      <input type="checkbox" name="arr[]" value="" />

      <input type="checkbox" name="arr[]" value="" />

      <input type="checkbox" name="arr[]" value="" />

      <input type="checkbox" name="arr[]" value="" />

    这样就可以使用$_POST["arr"]获得全部选中的checkbox的值了。

  • 相关阅读:
    推箱子
    去掉两个最高分、去掉两个最低分,求平均分
    投票选班长
    彩票
    闰年、平年
    闹钟
    手机号抽奖
    for练习--侦察兵
    兔子、棋盘放粮食、猴子吃桃
    for练习--凑法
  • 原文地址:https://www.cnblogs.com/xiaonian/p/3151107.html
Copyright © 2011-2022 走看看