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

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...
}

first though to pop in to my head:

$r=array_unique(array($week1, ...));
 if (count($r) !=17){

//error
}

Just loop through the pairs and compare them:

  $weeks=array();

   foreach(range(1,17) as $i)
   {
     array_push($weeks,'Week_' . $i);
   }

   foreach(range(1,16) as $i)
   {
     foreach(range($i+1,17) as $j)
       {
         if($_POST[$weeks[$i]]==$_POST[$weeks[$j]])
           {
             die("Rut-roh!");
           {
         }
       }
    }