View Full Version : Song Script

01-15-2012, 03:24 PM
Hello all,

I have included a song script below that links to a Shoutcast server (radio server). As some of the people know when I have posted about scripts before, I know extremely basic PHP.. doesn't really help haha.

Basically the "$text[6]" outputs a song that is currently being played by the server. It spits it out in the format of "Artist - Song Name" or "Artist - Song Name (feat. Artist Name)."

Is there anyone who knows how to take this script and recode it so that it strips the back end of the output, the "- Song Name" and only outputs what is before the hyphen (-)?

If anyone is capable to do it, it would be greatly appreciated as I have no idea where to start. Also, I hid the Server IP and Port but normally those areas would be numbers.

Thank you so much as always,

$open = fsockopen("SERVER IP","SERVER PORT");
if ($open) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read = fread($open,1000);
$text = explode("content-type:text/html",$read);
$text = explode(",",$text[1]);
} else { $er="Pixie Lott - Gravity"; }

if ($text[1]==1) { $state = "Up"; } else { $state = "Down"; }
if ($er) { echo $er; exit; }
echo "$text[6]";?>

01-15-2012, 03:49 PM
Change this

echo "$text[6]";
to this

$artistarr = explode('-',$text[6]);
echo trim($artistarr[0]);

01-15-2012, 04:05 PM
Thank you so much, works perfectly :)!