回答編集履歴

1

ソースの追加

2019/10/24 06:24

投稿

hanhunhun
hanhunhun

スコア100

test CHANGED
@@ -35,3 +35,59 @@
35
35
  ```
36
36
 
37
37
  $holidayを回し終わった後に比較では配列の最後しか比較されませんよ
38
+
39
+
40
+
41
+
42
+
43
+ 追記
44
+
45
+
46
+
47
+ 例置いときますね
48
+
49
+
50
+
51
+ ```PHP
52
+
53
+ $sch_html = '';
54
+
55
+ foreach($holiday as $key) {
56
+
57
+ $id = $key['id'];
58
+
59
+ $user = $key['account_id'];
60
+
61
+ $kana = $key['account_kana'];
62
+
63
+ $from = $key['datetime_from'];
64
+
65
+ $to = $key['datetime_from'];
66
+
67
+ $type = $key['holiday_type'];
68
+
69
+
70
+
71
+      if($from == $days){
72
+
73
+ $todayClass = ($day->format('Y-m-d') === $today->format('Y-m-d')) ? 'today' : '';
74
+
75
+ $sch_html = sprintf('<div class="cal cal_td" data-date="' . $days . '"><div class="cal_date day_%d %s">%d</div><div class="cal_plan"></div><div class="cal_body"><div class="area_btn" data-user="' . $user . ' data-user="' . $kana . ' "data-from="' . $from . '" data-to="' . $to . '" data-type="' . $type . '">' . $type . '/' . ' ' .$user .'</div></div></div>', $day->format('w'), $todayClass, $day->format('d'));
76
+
77
+ }
78
+
79
+ }
80
+
81
+ if($sch_html != '') {
82
+
83
+ $body .= $sch_html;
84
+
85
+ } else {
86
+
87
+ $todayClass = ($day->format('Y-m-d') === $today->format('Y-m-d')) ? 'today' : '';
88
+
89
+ $body .= sprintf('<div class="cal cal_td" data-date="' . $days . '"><div class="cal_date day_%d %s">%d</div><div class="cal_plan"></div><div class="cal_body"></div></div>', $day->format('w'), $todayClass, $day->format('d'));
90
+
91
+ }
92
+
93
+ ```