回答編集履歴
2
見直し
test
CHANGED
@@ -24,51 +24,51 @@
|
|
24
24
|
|
25
25
|
<?php
|
26
26
|
|
27
|
-
$plan0=array('id'=>
|
27
|
+
$plan0 = array('id' => '1',
|
28
|
-
|
28
|
+
|
29
|
-
'year'=>2020,
|
29
|
+
'year' => 2020,
|
30
|
-
|
30
|
+
|
31
|
-
'month'=>10,
|
31
|
+
'month' => 10,
|
32
|
-
|
32
|
+
|
33
|
-
'day'=>30,
|
33
|
+
'day' => 30,
|
34
|
-
|
34
|
+
|
35
|
-
'content'=>
|
35
|
+
'content' => 'さらに進める', );
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
-
$plan1=array('id'=>
|
39
|
+
$plan1 = array('id' => '2',
|
40
|
-
|
40
|
+
|
41
|
-
'year'=>2021,
|
41
|
+
'year' => 2021,
|
42
|
-
|
42
|
+
|
43
|
-
'month'=>11,
|
43
|
+
'month' => 11,
|
44
|
-
|
44
|
+
|
45
|
-
'day'=>01,
|
45
|
+
'day' => 01,
|
46
|
-
|
46
|
+
|
47
|
-
'content'=>
|
47
|
+
'content' => '頑張る', );
|
48
|
-
|
48
|
+
|
49
|
-
$plan2=array('id'=>
|
49
|
+
$plan2 = array('id' => '3',
|
50
|
-
|
50
|
+
|
51
|
-
'year'=>2019,
|
51
|
+
'year' => 2019,
|
52
|
-
|
52
|
+
|
53
|
-
'month'=>11,
|
53
|
+
'month' => 11,
|
54
|
-
|
54
|
+
|
55
|
-
'day'=>02,
|
55
|
+
'day' => 02,
|
56
|
-
|
56
|
+
|
57
|
-
'content'=>
|
57
|
+
'content' => 'もっと進める', );
|
58
|
-
|
58
|
+
|
59
|
-
$plan3=array('id'=>
|
59
|
+
$plan3 = array('id' => '4',
|
60
|
-
|
60
|
+
|
61
|
-
'year'=>2028,
|
61
|
+
'year' => 2028,
|
62
|
-
|
62
|
+
|
63
|
-
'month'=>10,
|
63
|
+
'month' => 10,
|
64
|
-
|
64
|
+
|
65
|
-
'day'=>29,
|
65
|
+
'day' => 29,
|
66
|
-
|
66
|
+
|
67
|
-
'content'=>
|
67
|
+
'content' => 'もっと進める', );
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
-
$plan=array($plan0,$plan1,$plan2,$plan3);
|
71
|
+
$plan = array($plan0,$plan1,$plan2,$plan3);
|
72
72
|
|
73
73
|
|
74
74
|
|
@@ -88,7 +88,7 @@
|
|
88
88
|
|
89
89
|
<h1>東京オリンピックまで</h1>
|
90
90
|
|
91
|
-
<h1>あと<?php echo mktime(20,0,0,7,24,2020)-time()?> 秒</h1>
|
91
|
+
<h1>あと<?php echo mktime(20, 0, 0, 7, 24, 2020) - time()?> 秒</h1>
|
92
92
|
|
93
93
|
|
94
94
|
|
@@ -118,70 +118,76 @@
|
|
118
118
|
|
119
119
|
<?php
|
120
120
|
|
121
|
-
foreach($plan as $key => $value){
|
121
|
+
foreach ($plan as $key => $value) {
|
122
122
|
|
123
123
|
// $plansの中身の数だけ繰り返す
|
124
124
|
|
125
125
|
// $keyにキーが格納され、$valueに値が格納される
|
126
126
|
|
127
|
-
$array_year[]=$value['year']
|
127
|
+
$array_year[] = $value['year'];
|
128
|
-
|
128
|
+
|
129
|
-
$array_month[]=$value['month']
|
129
|
+
$array_month[] = $value['month'];
|
130
|
-
|
130
|
+
|
131
|
-
$array_day[]=$value['day']
|
131
|
+
$array_day[] = $value['day'];
|
132
|
+
|
132
|
-
|
133
|
+
}
|
133
|
-
|
134
|
-
|
134
|
+
|
135
|
+
|
136
|
+
|
135
|
-
array_multisort($array_year,SORT_ASC,
|
137
|
+
array_multisort($array_year, SORT_ASC,
|
136
|
-
|
138
|
+
|
137
|
-
$array_month,SORT_ASC,
|
139
|
+
$array_month, SORT_ASC,
|
138
|
-
|
140
|
+
|
139
|
-
$array_day,SORT_ASC,
|
141
|
+
$array_day, SORT_ASC,
|
140
142
|
|
141
143
|
|
142
144
|
|
143
145
|
$plan);
|
144
146
|
|
145
|
-
foreach($plan as $key => $value){
|
147
|
+
foreach ($plan as $key => $value) {
|
148
|
+
|
149
|
+
?>
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
<tr>
|
154
|
+
|
155
|
+
<td><?php echo $plan[$key]['id']?></td>
|
156
|
+
|
157
|
+
<td><?php echo $plan[$key]['year']?></td>
|
158
|
+
|
159
|
+
<td><?php echo $plan[$key]['month']?></td>
|
160
|
+
|
161
|
+
<td><?php echo $plan[$key]['day']?></td>
|
162
|
+
|
163
|
+
<td><?php echo $plan[$key]['content']?></td>
|
164
|
+
|
165
|
+
<td><?php
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
if (mktime(0, 0, 0, $value['month'], $value['day'], $value['year']) < strtotime('time')) {
|
170
|
+
|
171
|
+
echo '過去';
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
echo mktime(0, 0, 0, $value['month'], $value['year'])?></td>
|
178
|
+
|
179
|
+
</tr>
|
180
|
+
|
181
|
+
<?php
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
}
|
146
186
|
|
147
187
|
?>
|
148
188
|
|
149
189
|
|
150
190
|
|
151
|
-
<tr>
|
152
|
-
|
153
|
-
<td><?php echo $plan[$key]['id']?></td>
|
154
|
-
|
155
|
-
<td><?php echo $plan[$key]['year']?></td>
|
156
|
-
|
157
|
-
<td><?php echo $plan[$key]['month']?></td>
|
158
|
-
|
159
|
-
<td><?php echo $plan[$key]['day']?></td>
|
160
|
-
|
161
|
-
<td><?php echo $plan[$key]['content']?></td>
|
162
|
-
|
163
|
-
<td><?php
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
if(mktime(0,0,0,$value["month"],$value["day"],$value["year"])<strtotime("time")){
|
168
|
-
|
169
|
-
echo "過去";}
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
echo mktime(0,0,0,$value["month"],$value["year"])?></td>
|
174
|
-
|
175
|
-
</tr>
|
176
|
-
|
177
|
-
<?php
|
178
|
-
|
179
|
-
}
|
180
|
-
|
181
|
-
?>
|
182
|
-
|
183
|
-
|
184
|
-
|
185
191
|
</table>
|
186
192
|
|
187
193
|
|
@@ -193,3 +199,9 @@
|
|
193
199
|
```
|
194
200
|
|
195
201
|
としたら、とりあえず4行分表示しています。
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
例えば、整形ツールを使ってみると良いです。
|
206
|
+
|
207
|
+
[PHPソースコード整形(PHP Beautifier,php-cs-fixer)](https://flatsystems.net/php_beautifier.php)
|
1
見直し
test
CHANGED
@@ -17,3 +17,179 @@
|
|
17
17
|
繰り返しって、これで完結しちゃってますが。
|
18
18
|
|
19
19
|
繰り返して、最後の`$key`が使われて、一行分表示しているのかと。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```php
|
24
|
+
|
25
|
+
<?php
|
26
|
+
|
27
|
+
$plan0=array('id'=>"1",
|
28
|
+
|
29
|
+
'year'=>2020,
|
30
|
+
|
31
|
+
'month'=>10,
|
32
|
+
|
33
|
+
'day'=>30,
|
34
|
+
|
35
|
+
'content'=>"さらに進める");
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
$plan1=array('id'=>"2",
|
40
|
+
|
41
|
+
'year'=>2021,
|
42
|
+
|
43
|
+
'month'=>11,
|
44
|
+
|
45
|
+
'day'=>01,
|
46
|
+
|
47
|
+
'content'=>"頑張る");
|
48
|
+
|
49
|
+
$plan2=array('id'=>"3",
|
50
|
+
|
51
|
+
'year'=>2019,
|
52
|
+
|
53
|
+
'month'=>11,
|
54
|
+
|
55
|
+
'day'=>02,
|
56
|
+
|
57
|
+
'content'=>"もっと進める");
|
58
|
+
|
59
|
+
$plan3=array('id'=>"4",
|
60
|
+
|
61
|
+
'year'=>2028,
|
62
|
+
|
63
|
+
'month'=>10,
|
64
|
+
|
65
|
+
'day'=>29,
|
66
|
+
|
67
|
+
'content'=>"もっと進める");
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
$plan=array($plan0,$plan1,$plan2,$plan3);
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
?><!DOCTYPE html>
|
76
|
+
|
77
|
+
<html lang="ja">
|
78
|
+
|
79
|
+
<head>
|
80
|
+
|
81
|
+
<title>PHP練習</title>
|
82
|
+
|
83
|
+
<meta charset="UTF-8">
|
84
|
+
|
85
|
+
</head>
|
86
|
+
|
87
|
+
<body bgcolor="e6e6fa">
|
88
|
+
|
89
|
+
<h1>東京オリンピックまで</h1>
|
90
|
+
|
91
|
+
<h1>あと<?php echo mktime(20,0,0,7,24,2020)-time()?> 秒</h1>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<h1>多次元配列</h1>
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<table border='1'>
|
100
|
+
|
101
|
+
<tr>
|
102
|
+
|
103
|
+
<td>id</td>
|
104
|
+
|
105
|
+
<td>year</td>
|
106
|
+
|
107
|
+
<td>month</td>
|
108
|
+
|
109
|
+
<td>day</td>
|
110
|
+
|
111
|
+
<td>content</td>
|
112
|
+
|
113
|
+
<td>過去、本日、未来</td>
|
114
|
+
|
115
|
+
</tr>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<?php
|
120
|
+
|
121
|
+
foreach($plan as $key => $value){
|
122
|
+
|
123
|
+
// $plansの中身の数だけ繰り返す
|
124
|
+
|
125
|
+
// $keyにキーが格納され、$valueに値が格納される
|
126
|
+
|
127
|
+
$array_year[]=$value['year'] ;
|
128
|
+
|
129
|
+
$array_month[]=$value['month'] ;
|
130
|
+
|
131
|
+
$array_day[]=$value['day'] ;}
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
array_multisort($array_year,SORT_ASC,
|
136
|
+
|
137
|
+
$array_month,SORT_ASC,
|
138
|
+
|
139
|
+
$array_day,SORT_ASC,
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
$plan);
|
144
|
+
|
145
|
+
foreach($plan as $key => $value){
|
146
|
+
|
147
|
+
?>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<tr>
|
152
|
+
|
153
|
+
<td><?php echo $plan[$key]['id']?></td>
|
154
|
+
|
155
|
+
<td><?php echo $plan[$key]['year']?></td>
|
156
|
+
|
157
|
+
<td><?php echo $plan[$key]['month']?></td>
|
158
|
+
|
159
|
+
<td><?php echo $plan[$key]['day']?></td>
|
160
|
+
|
161
|
+
<td><?php echo $plan[$key]['content']?></td>
|
162
|
+
|
163
|
+
<td><?php
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
if(mktime(0,0,0,$value["month"],$value["day"],$value["year"])<strtotime("time")){
|
168
|
+
|
169
|
+
echo "過去";}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
echo mktime(0,0,0,$value["month"],$value["year"])?></td>
|
174
|
+
|
175
|
+
</tr>
|
176
|
+
|
177
|
+
<?php
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
?>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
</table>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
</body>
|
190
|
+
|
191
|
+
</html>
|
192
|
+
|
193
|
+
```
|
194
|
+
|
195
|
+
としたら、とりあえず4行分表示しています。
|