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

有帮助吗?

解决方案

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);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top