function track_data() { $tracks = CMP3File::get_tracks(TRACKS_LOCATION); $data = ["total_tracks" => count($tracks), "tracks_location" => TRACKS_LOCATION, "tracks_size" => format_bytes(folder_size(TRACKS_LOCATION))]; return $data; }
<?php header("Content-Type", "text/json"); include "inc/inc.php"; $data = []; $tracks = CMP3File::get_tracks(TRACKS_LOCATION); foreach ($tracks as $track) { $data[substr(md5($track->filename), 0, 9)] = ["track_src" => $track->filename, "track_name" => $track->title, "track_album" => $track->album, "artist_name" => $track->artist]; } echo json_encode($data);