Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Song Script

  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    11
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Song Script

    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,
    Petey

    PHP Code:
    <? 
    $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]";?>

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    PHP Code:
    echo "$text[6]"
    to this
    PHP Code:
    $artistarr explode('-',$text[6]);
    echo 
    trim($artistarr[0]); 
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    peteyshivery (01-15-2012)

  • #3
    New Coder
    Join Date
    Dec 2011
    Posts
    11
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Thank you so much, works perfectly !


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •