avm99963 | b2a3fa9 | 2020-12-21 16:07:29 +0100 | [diff] [blame] | 1 | <?php |
| 2 | $rawJson = file_get_contents("php://stdin"); |
| 3 | $json = json_decode($rawJson, true); |
| 4 | |
| 5 | $students = []; |
| 6 | foreach ($json['songs'] as $song) { |
| 7 | foreach ($song["performers"] as $instrument) { |
| 8 | foreach ($instrument['names'] as $s) { |
| 9 | if (!isset($students[$s])) $students[$s] = []; |
| 10 | $students[$s][] = $song; |
| 11 | } |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | foreach ($students as $s => $songs) { |
| 16 | echo '==='.$s.'==='.PHP_EOL; |
| 17 | foreach ($songs as $song) { |
| 18 | echo ' - '.$song['begins'].' '.$song['title'].' '.PHP_EOL; |
| 19 | } |
| 20 | echo PHP_EOL; |
| 21 | } |