How can one make a for loop to compare variables like this (any language really but specifically for php):
Say I have var1 var2 var3 and I want an action to happen if two of the values are the same.
This is what I have but obviously it doesn't work as var1 will always equal var1, var2 will always equal var2 etc.
<?php for ($i = 1; $i <= 10; ++$i) {
if (${'var'.$i} == ${'var'.$i}) {
// if match do something
}
else {
do something
}
Attempt for array_unique.
<?php
for ($i = 1; $i <= $number_of_seats; ++$i) {
$choices = array_unique(array("${'selected_seat'.$i}"));
if (count(${'selected_seat'.$i}) !== count($choices)) {
echo 'action="fail.php"';
}
else {
echo 'action="success.php"';
}
}
?> method="post">
array_unique
? i.e.$choices = array_unique($input); if (count($input) !== count($choices)) { ...
. A more complete question may yield a more complete answer. – AD7six