よく忘れるので書いておきます。
ループでフォームを回したときの値を取り出す方法です。
例えばこんな感じ。
スポンサーリンク
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <form action="" method="post"> <input type="text" name="text[0]" /> <input type="submit" name="input[0]" value="テキスト入力" /> </form> <form action="" method="post"> <input type="text" name="text[1]" /> <input type="submit" name="input[1]" value="テキスト入力" /> </form> <form action="" method="post"> <input type="text" name="text[2]" /> <input type="submit" name="input[2]" value="テキスト入力" /> </form> |
とりあえずnameを配列のようにするそして
1 2 3 4 5 6 | <?php if(isset($_POST['input'])){ $key = key($_POST['input']); echo $_POST['text'][$key]; };?> |
key関数で配列の数字を取り出してあと当てはめるという結構単純!
だけどすぐ忘れる。。。。なぜだろう。。。