Last.fm Group Chart with Similar Tracks

Trying to write the outline for a script to build playlists from Last.fm data. There may a line or so missing, because I am coding with no real background in it, using building blocks from about the site. Let me know if there are improvements needed and I will endeavour to touch it up. If it works, this could then be modified to create autoplaylists from various points of Last.fm data - such as their charts - as well as other places that create API-style playlists.
Hmmm.. wait what?

So you should be putting these into a $keys array (this is what you read later on on line 200). You should initialise that array before it's first used like this:

$keys = [];

(like how playlist is done on 197)