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'?

Était-ce utile?

La 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);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top