Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
// so viele variablen kann es geben also 0 - 19
$max = 20;
for($i=0; $i < $max; $i++)
{
$name = "mail".$i;
if(isset($$name))
{
echo $$name;
}
}
$mails = array();
for ($i = 1; isset($_POST["mail$i"]); ++$i)
array_push($mails, $_POST["mail$i"]);
Genau genommen kann man das ;)Mann kann die Felder ja nicht mail[1], mail[2], usw. nennen...
<?php
for ($i=0; $i<=5; $i++)
{
$mail[$i] = stripslashes(htmlentities($_POST["mail[$i]"]));
}
?>
Erstens müsste deine Zuweisung so aussehen:
Und zweitens ist sie unnötig:PHP:$mail[$i] = $_POST['mail'][$i];
PHP:$mail = $_POST['mail'];
EDIT:
Und drittens hast du nur fünf Werte, die Schleife liefe aber sechs mal durch: 0 1 2 3 4 5 ;)
$mail = stripslashes(htmlentities($_POST['mail']));
for ($i=1; $i<=4; $i++)
{
for ($j=$i+1; $j<=5; $j++)
{
if ($mail[$i] == $mail[$j] && !empty($mail[$i]))
{
$fehler[] = "Mindestens zwei E-Mail Adressen deiner Freunde sind identisch!";
}
}
}
Ist mir dann auch noch eingefallen.Hm klappt ja doch nicht.
Wenn nämlich keine oder nur wenige E-Mail Adressen eingegeben werden, kommt trotzdem die Meldung "Mindestens zwei der Adressen sind identisch."
$mail = array_unique($mail);
$mailohne = array_diff($mail, array(''));
if($mailohne != array_unique($mailohne)) $fehler[] = "Mindestens zwei der E-Mail Adressen sind identisch!";