予定を表示するカレンダーをつくっているのですが、予定の部分をjsonから読み取る仕様にしたいと思っています。
下記jsonです。
json
1 2 {"res": 3 {"ScheduleData":[ 4 { 5 "id":"0001", 6 "title":"サンプル01", 7 "day":[ 8 { 9 "year":"2018", 10 "month":"03", 11 "_day":"31" 12 } 13 ], 14 "appoint_1":"単体テスト", 15 "appoint_2":"javascript勉強会", 16 "appoint_3":"新規プロジェクトキックオフ", 17 }, 18 { 19 "id":"0002", 20 "title":"サンプル02", 21 "day":[ 22 { 23 "year":"2018", 24 "month":"04", 25 "_day":"01" 26 } 27 ], 28 "appoint_1":"会議", 29 "appoint_2":"要件定義", 30 "appoint_3":"ログ収集機能改修", 31 } 32 ]} 33 } 34
php
1 private function _getTail() { 2 3 $url = "jsondata.json"; 4 $json = file_get_contents($url); 5 $arr = json_decode($json, true); 6 7 8 $tail = ''; 9 $lastDayOfPrevMonth = new \DateTime('last day of ' . $this->yearMonth . ' -1 month'); 10 while ($lastDayOfPrevMonth->format('w') < 6) { 11 $tail_pre = sprintf('<td class="gray">%d', $lastDayOfPrevMonth->format('d')); 12 13 $tail_appoint_1 = sprintf('<ul><li>%s</li>', $arr["res"]["ScheduleData"][0]["appoint_1"]); ←※1 14 $tail_appoint_2 = sprintf('<li>%s</li></td>', $arr["res"]["ScheduleData"][0]["appoint_2"]); 15 $tail = $tail_pre . $tail_appoint_1 . $tail_appoint_2 . $tail; 16 17 $lastDayOfPrevMonth->sub(new \DateInterval('P1D')); 18 } 19 return $tail; 20 } 21
上記のphpの※1のところをforeachで回してid:0001とid:0002もそしてさらに増えても取得してカレンダーに表示できるようにしたいのですが、どのように書き換えるべきでしょうか。