回答編集履歴
2
ちょうせい
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
命題通りにやるならこうです
|
2
2
|
|
3
|
-
|
3
|
+
(一部微調整)
|
4
4
|
|
5
5
|
```PHP
|
6
6
|
|
@@ -8,13 +8,13 @@
|
|
8
8
|
|
9
9
|
$name=["number","maintenance","money"];
|
10
10
|
|
11
|
-
$num=
|
11
|
+
$num=range(1,5);
|
12
12
|
|
13
13
|
foreach($name as $val1){
|
14
14
|
|
15
15
|
foreach($num as $val2){
|
16
16
|
|
17
|
-
${$val1.$val2}=filter_input(INPUT_POST,$val1.$val2);
|
17
|
+
${$val1."0".$val2}=filter_input(INPUT_POST,$val1."0".$val2);
|
18
18
|
|
19
19
|
}
|
20
20
|
|
1
chousei
test
CHANGED
@@ -65,3 +65,67 @@
|
|
65
65
|
</form>
|
66
66
|
|
67
67
|
```
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
# 配列処理
|
72
|
+
|
73
|
+
配列で処理するほうが楽
|
74
|
+
|
75
|
+
```PHP
|
76
|
+
|
77
|
+
<?PHP
|
78
|
+
|
79
|
+
$name=["number","maintenance","money"];
|
80
|
+
|
81
|
+
foreach($name as $val){
|
82
|
+
|
83
|
+
$$val=filter_input(INPUT_POST,$val,FILTER_DEFAULT,FILTER_REQUIRE_ARRAY);
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
var_dump($number[1]);
|
88
|
+
|
89
|
+
var_dump($maintenance[3]);
|
90
|
+
|
91
|
+
var_dump($money[5]);
|
92
|
+
|
93
|
+
?>
|
94
|
+
|
95
|
+
<form method="post">
|
96
|
+
|
97
|
+
number01:<input type="text" name="number[1]" value="1"><br>
|
98
|
+
|
99
|
+
maintenance01:<input type="text" name="maintenance[1]" value="a"><br>
|
100
|
+
|
101
|
+
money01:<input type="text" name="money[1]" value="100"><br>
|
102
|
+
|
103
|
+
number02:<input type="text" name="number[2]" value="2"><br>
|
104
|
+
|
105
|
+
maintenance02:<input type="text" name="maintenance[2]" value="b"><br>
|
106
|
+
|
107
|
+
money02:<input type="text" name="money[2]" value="200"><br>
|
108
|
+
|
109
|
+
number03:<input type="text" name="number[3]" value="3"><br>
|
110
|
+
|
111
|
+
maintenance03:<input type="text" name="maintenance[3]" value="c"><br>
|
112
|
+
|
113
|
+
money03:<input type="text" name="money[3]" value="300"><br>
|
114
|
+
|
115
|
+
number04:<input type="text" name="number[4]" value="4"><br>
|
116
|
+
|
117
|
+
maintenance04:<input type="text" name="maintenance[4]" value="d"><br>
|
118
|
+
|
119
|
+
money04:<input type="text" name="money[4]" value="400"><br>
|
120
|
+
|
121
|
+
number05:<input type="text" name="number[5]" value="5"><br>
|
122
|
+
|
123
|
+
maintenance05:<input type="text" name="maintenance[5]" value="e"><br>
|
124
|
+
|
125
|
+
money05:<input type="text" name="money[5]" value="500"><br>
|
126
|
+
|
127
|
+
<input type="submit" value="send">
|
128
|
+
|
129
|
+
</form>
|
130
|
+
|
131
|
+
```
|