命題通りにやるならこうです
(一部微調整)
PHP
1<?PHP
2$name=["number","maintenance","money"];
3$num=range(1,5);
4foreach($name as $val1){
5 foreach($num as $val2){
6 ${$val1."0".$val2}=filter_input(INPUT_POST,$val1."0".$val2);
7 }
8}
9var_dump($number01);
10var_dump($maintenance03);
11var_dump($money05);
12?>
13<form method="post">
14number01:<input type="text" name="number01" value="1"><br>
15maintenance01:<input type="text" name="maintenance01" value="a"><br>
16money01:<input type="text" name="money01" value="100"><br>
17number02:<input type="text" name="number02" value="2"><br>
18maintenance02:<input type="text" name="maintenance02" value="b"><br>
19money02:<input type="text" name="money02" value="200"><br>
20number03:<input type="text" name="number03" value="3"><br>
21maintenance03:<input type="text" name="maintenance03" value="c"><br>
22money03:<input type="text" name="money03" value="300"><br>
23number04:<input type="text" name="number04" value="4"><br>
24maintenance04:<input type="text" name="maintenance04" value="d"><br>
25money04:<input type="text" name="money04" value="400"><br>
26number05:<input type="text" name="number05" value="5"><br>
27maintenance05:<input type="text" name="maintenance05" value="e"><br>
28money05:<input type="text" name="money05" value="500"><br>
29<input type="submit" value="send">
30</form>
配列処理
配列で処理するほうが楽
PHP
1<?PHP
2$name=["number","maintenance","money"];
3foreach($name as $val){
4 $$val=filter_input(INPUT_POST,$val,FILTER_DEFAULT,FILTER_REQUIRE_ARRAY);
5}
6var_dump($number[1]);
7var_dump($maintenance[3]);
8var_dump($money[5]);
9?>
10<form method="post">
11number01:<input type="text" name="number[1]" value="1"><br>
12maintenance01:<input type="text" name="maintenance[1]" value="a"><br>
13money01:<input type="text" name="money[1]" value="100"><br>
14number02:<input type="text" name="number[2]" value="2"><br>
15maintenance02:<input type="text" name="maintenance[2]" value="b"><br>
16money02:<input type="text" name="money[2]" value="200"><br>
17number03:<input type="text" name="number[3]" value="3"><br>
18maintenance03:<input type="text" name="maintenance[3]" value="c"><br>
19money03:<input type="text" name="money[3]" value="300"><br>
20number04:<input type="text" name="number[4]" value="4"><br>
21maintenance04:<input type="text" name="maintenance[4]" value="d"><br>
22money04:<input type="text" name="money[4]" value="400"><br>
23number05:<input type="text" name="number[5]" value="5"><br>
24maintenance05:<input type="text" name="maintenance[5]" value="e"><br>
25money05:<input type="text" name="money[5]" value="500"><br>
26<input type="submit" value="send">
27</form>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/10/24 09:21