PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $albums = array( 1 => ['title' => 'The Dark Side of the Moon', 'date' => 1973, 'country' => 'Великобритания', 'id_team' => 2], 2 => ['title' => 'Wish You Were Here', 'date' => 1975, 'country' => 'Великобритания', 'id_team' => 2], 3 => ['title' => 'Greatest Hits', 'date' => 1999, 'country' => 'США', 'id_team' => 2], 4 => ['title' => 'Abbey Road', 'date' => 1969, 'country' => 'Великобритания', 'id_team' => 3], 5 => ['title' => 'A Hard Day\'s Night', 'date' => 1964, 'country' => 'Великобритания', 'id_team' => 3], 6 => ['title' => 'Back in Black', 'date' => 1980, 'country' => 'США', 'id_team' => 4], 7 => ['title' => 'Highway to Hell', 'date' => 1979, 'country' => 'Австралия', 'id_team' => 4], 8 => ['title' => 'The Razors Edge', 'date' => 1990, 'country' => 'Австралия', 'id_team' => 4], 9 => ['title' => 'Let There Be Rock', 'date' => 1977, 'country' => 'ФРГ', 'id_team' => 4], 10 => ['title' => 'Rocks', 'date' => 1982, 'country' => 'Великобритания', 'id_team' => 1], 11 => ['title' => 'Strange Days', 'date' => 1967, 'country' => 'США', 'id_team' => 0], 12 => ['title' => 'L.A. Woman', 'date' => 1971, 'country' => 'США', 'id_team' => 0], 13 => ['title' => 'Greatest Hits', 'date' => 1978, 'country' => 'США', 'id_team' => 3], ); $tracks = array( 1 => ['name' => 'Back in the Saddle', 'note' => '', 'id_album' => 10], 2 => ['name' => 'Last Child', 'note' => '', 'id_album' => 10], 3 => ['name' => 'Rats in the Cellar', 'note' => '', 'id_album' => 10], 4 => ['name' => 'Combination', 'note' => '', 'id_album' => 10], 5 => ['name' => 'Sick As a Dog', 'note' => '', 'id_album' => 10], 6 => ['name' => 'Come Together', 'note' => '', 'id_album' => 10], 7 => ['name' => 'Get the Lead Out', 'note' => '', 'id_album' => 10], 8 => ['name' => 'Lick and a Promise', 'note' => '', 'id_album' => 10], 9 => ['name' => 'Home Tonight', 'note' => '', 'id_album' => 10], 10 => ['name' => 'Come Together', 'note' => '', 'id_album' => 4], 11 => ['name' => 'Something', 'note' => '', 'id_album' => 4], 12 => ['name' => 'Maxwell\'s Silver Hammer', 'note' => '', 'id_album' => 4], 13 => ['name' => 'Oh! Darling', 'note' => '', 'id_album' => 4], 14 => ['name' => 'Octopus\'s Garden', 'note' => '', 'id_album' => 4], 15 => ['name' => 'I Want You (She\'s So Heavy)', 'note' => '', 'id_album' => 4], 16 => ['name' => 'Here Comes The Sun', 'note' => '', 'id_album' => 4], 17 => ['name' => 'Because', 'note' => '', 'id_album' => 4], 18 => ['name' => 'You Never Give Me Your Money', 'note' => '', 'id_album' => 4], 19 => ['name' => 'Sun King', 'note' => '', 'id_album' => 4], 20 => ['name' => 'Mean Mr Mustard', 'note' => '', 'id_album' => 4], 21 => ['name' => 'Polythene Pam', 'note' => '', 'id_album' => 4], 22 => ['name' => 'Shine On You Crazy Diamond (Part One)', 'note' => '', 'id_album' => 2], 23 => ['name' => 'Welcome to the Machine', 'note' => '', 'id_album' => 2], 24 => ['name' => 'Have a Cigar', 'note' => '', 'id_album' => 2], 25 => ['name' => 'Wish You Were Here', 'note' => '', 'id_album' => 2], 26 => ['name' => 'Shine On You Crazy Diamond (Part Two)', 'note' => '', 'id_album' => 2], 27 => ['name' => 'Speak to Me', 'note' => '', 'id_album' => 1], 28 => ['name' => 'Breathe (In the Air)', 'note' => '', 'id_album' => 1], 29 => ['name' => 'On the Run', 'note' => '', 'id_album' => 1], 30 => ['name' => 'Time', 'note' => '', 'id_album' => 1], 31 => ['name' => 'The Great Gig in the Sky', 'note' => '', 'id_album' => 1], 32 => ['name' => 'Money', 'note' => '', 'id_album' => 1], 33 => ['name' => 'Us and Them', 'note' => '', 'id_album' => 1], 34 => ['name' => 'Any Colour You Like', 'note' => '', 'id_album' => 1], 35 => ['name' => 'Brain Damage', 'note' => '', 'id_album' => 1], 36 => ['name' => 'Eclipse', 'note' => '', 'id_album' => 1], 37 => ['name' => 'Hells Bells', 'note' => '', 'id_album' => 6], 38 => ['name' => 'Shoot to Thrill', 'note' => '', 'id_album' => 6], 39 => ['name' => 'What Do You Do for Money Honey', 'note' => '', 'id_album' => 6], 40 => ['name' => 'Given the Dog a Bone', 'note' => '', 'id_album' => 6], 41 => ['name' => 'Let Me Put My Love Into You', 'note' => '', 'id_album' => 6], 42 => ['name' => 'Back in Black', 'note' => '', 'id_album' => 6], 43 => ['name' => 'You Shook Me All Night Long', 'note' => '', 'id_album' => 6], 44 => ['name' => 'Have a Drink on Me', 'note' => '', 'id_album' => 6], 45 => ['name' => 'Shake a Leg', 'note' => '', 'id_album' => 6], 46 => ['name' => 'Rock and Roll Ain\'t Noise Pollution', 'note' => '', 'id_album' => 6], 47 => ['name' => 'Strange Days', 'note' => '', 'id_album' => 0], 48 => ['name' => 'You\'re Lost Little Girl', 'note' => '', 'id_album' => 11], 49 => ['name' => 'Love Me Two Times', 'note' => '', 'id_album' => 11], 50 => ['name' => 'Unhappy Girl', 'note' => '', 'id_album' => 11], 51 => ['name' => 'Horse Latitudes', 'note' => '', 'id_album' => 11], 52 => ['name' => 'Moonlight Drive', 'note' => '', 'id_album' => 11], 53 => ['name' => 'People Are Strange', 'note' => '', 'id_album' => 11], 54 => ['name' => 'My Eyes Have Seen You', 'note' => '', 'id_album' => 11], 55 => ['name' => 'I Can\'t See Your Face in My Mind', 'note' => '', 'id_album' => 11], 56 => ['name' => 'When the Music\'s Over', 'note' => '', 'id_album' => 11], ); function showAlbum(array $albumData, array $albumTracks): void { echo '<h1>'.$albumData['title'].'</h1>'.PHP_EOL; if (count($albumTracks)) { echo '<ul>'.PHP_EOL; } foreach ($albumTracks as $track) { echo ' <li>'.$track['name'].'</li>'.PHP_EOL; } if (count($albumTracks)) { echo '</ul>'.PHP_EOL; } else { echo 'Нет треков в альбоме'.PHP_EOL; } } $albumsToShow = $_GET['id'] ? [$_GET['id']] : array_keys($albums); foreach ($albumsToShow as $albumID) { $albumTracks = array_filter($tracks, function ($t) use ($albumID) { return $t['id_album'] === $albumID; }); showAlbum($albums[$albumID], $albumTracks); }
Show:  
Copy Clear