blob: 8ea32ab187fd37de4965103b783555ea57c3e7db [file] [log] [blame]
avm99963b2a3fa92020-12-21 16:07:29 +01001<?php
2$rawJson = file_get_contents("php://stdin");
3$json = json_decode($rawJson, true);
4
5$students = [];
6foreach ($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
15foreach ($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}