문제

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