Question

I have a SHOUTcast server which has an API to show the track and artist. It uses javascript to show the information and looks like this:

Bon Jovi - You Give Love a Bad Name

To get more information about the track I'd like to send it to the Last.fm API. The Last.fm API is setup but the artist and track need to be sent separately.

Is there a way you can use PHP to make $artist = 'Bon Jovi' and $track = 'You Give Love a Bad Name'?

Was it helpful?

Solution

You could use the explode function:

$song = explode('-','Bon Jovi - You Give Love a Bad Name')
$artist = substr($song[0],1);
$track = substr($song[1],1);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top