$playedAlready = Array();//Empty array, as we haven't played any yet.
$randNum = round(rand(0,$playlist.length));//This would round to a whole number, and return a random value between 0 and the number of items in the $playlist variable
Spotify::Play($playlist[$randNum]); //Plays a random track from the playlist
$playedAlready = $playlist[$randNum];//Adds this track to the playedAlready list unset($playlist[$randNum]);//This then deletes the song entry from the playlist, so it can't possibly be part of the random selection again
//After the song has finished, the above process is looped.
This is obviously a very basic concept but the idea is there.
Why haven't the Spotify team implemented something as simple as that?