私はこの「マスターマインドゲーム」を今何時間も働かせようとしていますが、array_intersect
でも正しく動作せず、新しいアレイとして最初のアレイを受け取るだけです。同じ値(および位置)の2つの配列を比較していますか?
私の2の目標は以下のとおりです。正しい数字の正しい位置の
- 額
- 額
コード:
<?php
$counter = $_POST['counter'];
$eins = $_POST['eins'];
$zwei = $_POST['zwei'];
$drei = $_POST['drei'];
$vier = $_POST['vier'];
$fuenf = $_POST['fuenf'];
if($counter > 0){
$elf = $_POST['elf'];
$zwoelf = $_POST['zwoelf'];
$dreizehn = $_POST['dreizehn'];
$vierzehn = $_POST['vierzehn'];
$fuenfzehn = $_POST['fuenfzehn'];
}
else{
$elf = 0;
$zwoelf = 0;
$dreizehn = 0;
$vierzehn = 0;
$fuenfzehn = 0;
}
$inputeins[0] = $eins;
$inputeins[1] = $zwei;
$inputeins[2] = $drei;
$inputeins[3] = $vier;
$inputeins[4] = $fuenf;
$inputdrei[0] = $elf;
$inputdrei[1] = $zwoelf;
$inputdrei[2] = $dreizehn;
$inputdrei[3] = $vierzehn;
$inputdrei[4] = $fuenfzehn;
if($inputeins == $inputdrei){
echo "<br><a href='ratespiel.html' style='font-size:100px;'>Gewonnen!</a>";
}
else{
if($counter < 12){
echo "<form action='ratespielzwei.php' method='post'>";
echo "Ziffern von Spieler 2:<br><br>";
echo "<input type='number' name='counter' value='$counter' hidden>";
echo "<input type='number' name='eins' value='$eins' hidden>";
echo "<input type='number' name='zwei' value='$zwei' hidden>";
echo "<input type='number' name='drei' value='$drei' hidden>";
echo "<input type='number' name='vier' value='$vier' hidden>";
echo "<input type='number' name='fuenf' value='$fuenf' hidden>";
echo "<input type='number' min='1' max='5' name='sechs' style='width:30px;' required> ";
echo "<input type='number' min='1' max='5' name='sieben' style='width:30px;' required> ";
echo "<input type='number' min='1' max='5' name='acht' style='width:30px;' required> ";
echo "<input type='number' min='1' max='5' name='neun' style='width:30px;' required> ";
echo "<input type='number' min='1' max='5' name='zehn' style='width:30px;' required> ";
echo "<input type='submit' min='1' max='5' name='submitzwei' value='OK'><br><br>";
echo "</form>";
}
else{
echo "<br><a href='ratespiel.html' style='font-size:100px;'>Verloren!</a>";
}
}
if($counter > 0){
foreach ($inputdrei as $ausgabe){
echo "$ausgabe ";
}
}
?>
と
<?php
$counter = $_POST['counter'];
$i = $counter + 1;
$eins = $_POST['eins'];
$zwei = $_POST['zwei'];
$drei = $_POST['drei'];
$vier = $_POST['vier'];
$fuenf = $_POST['fuenf'];
$sechs = $_POST['sechs'];
$sieben = $_POST['sieben'];
$acht = $_POST['acht'];
$neun = $_POST['neun'];
$zehn = $_POST['zehn'];
$inputeins[0] = $eins;
$inputeins[1] = $zwei;
$inputeins[2] = $drei;
$inputeins[3] = $vier;
$inputeins[4] = $fuenf;
$inputzwei[0] = $sechs;
$inputzwei[1] = $sieben;
$inputzwei[2] = $acht;
$inputzwei[3] = $neun;
$inputzwei[4] = $zehn;
while($counter <= $i){
$counter++;
}
if($inputeins == $inputzwei){
echo "<br><a href='ratespiel.html' style='font-size:100px;'>Gewonnen!</a>";
}
else{
echo "<form action='ratespieleins.php' method='post'>";
echo "Ziffern von Spieler 2:<br><br>";
echo "<input type='number' name='counter' value='$counter' hidden>";
echo "<input type='number' name='eins' value='$eins' hidden>";
echo "<input type='number' name='zwei' value='$zwei' hidden>";
echo "<input type='number' name='drei' value='$drei' hidden>";
echo "<input type='number' name='vier' value='$vier' hidden>";
echo "<input type='number' name='fuenf' value='$fuenf' hidden>";
echo "<input type='number' min='1' max='5' name='elf' style='width:30px;' required> ";
echo "<input type='number' min='1' max='5' name='zwoelf' style='width:30px;' required> ";
echo "<input type='number' min='1' max='5' name='dreizehn' style='width:30px;' required> ";
echo "<input type='number' min='1' max='5' name='vierzehn' style='width:30px;' required> ";
echo "<input type='number' min='1' max='5' name='fuenfzehn' style='width:30px;' required> ";
echo "<input type='submit' name='submitdrei' value='OK'><br><br>";
echo "</form>";
}
foreach ($inputzwei as $ausgabe){
echo "$ausgabe ";
}
?>
あなたは最小限の作業例を与えることができますので、我々は全体のコードを勉強しなくても問題を見ることができましたか? https://stackoverflow.com/help/mcve – user4035
私はまだnewbですが、私は例を追加しました。正直言って、私は私の2つの目標を達成するための手がかりがありません。 – blasthrop
解決策を質問の中に掲載しないでください。あなた自身の答えを作成してください。 – k0pernikus