doucan1996 2011-08-29 23:20
浏览 24
已采纳

PHP $ _POST验证

Is there a quick and easy way to check if any of my $_POST data has the same value?

I need it as a conditional statement...

Example:

$week1 = $_POST['Week_1'];
$week2 = $_POST['Week_2'];
$week3 = $_POST['Week_3'];
$week4 = $_POST['Week_4'];
$week5 = $_POST['Week_5'];
$week6 = $_POST['Week_6'];
$week7 = $_POST['Week_7'];
$week8 = $_POST['Week_8'];
$week9 = $_POST['Week_9'];
$week10 = $_POST['Week_10'];
$week11 = $_POST['Week_11'];
$week12 = $_POST['Week_12'];
$week13 = $_POST['Week_13'];
$week14 = $_POST['Week_14'];
$week15 = $_POST['Week_15'];
$week16 = $_POST['Week_16'];
$week17 = $_POST['Week_17'];

If the values of any of the weeks = equal the value of any of the other weeks, error...

Is there a quick way to do this in PHP?

Thanks!

Chris

  • 写回答

3条回答 默认 最新

  • doupin5408 2011-08-29 23:28
    关注

    If the only $_POST values you have are 'Week_1' through 'Week_17' then

    if (count(array_unique($_POST))  ===  count($_POST)) {
      //all unique values, do stuff...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序