Sleeper Posted July 13, 2011 Share Posted July 13, 2011 I am working on a shoutcast now playing script. The $songtitle comes out like.. artist name - song name However I want to just use the artist name and song name separate. So is there a way using php to grab everything before the "-" for one and then everything after the "-" for the other? So I could then have Artist: artist Name Title : song name Unfortunately shoutcast doesn't provide this info separately so I figured there has to be a php trick to do this. Link to comment https://forums.phpfreaks.com/topic/241926-seperate-at/ Share on other sites More sharing options...
requinix Posted July 13, 2011 Share Posted July 13, 2011 explode Link to comment https://forums.phpfreaks.com/topic/241926-seperate-at/#findComment-1242424 Share on other sites More sharing options...
Sleeper Posted July 13, 2011 Author Share Posted July 13, 2011 Just sorted that out I can do $s = explode("-",$songtitle); echo"Artist: $s[0] Title: $s[1]; Thanks Link to comment https://forums.phpfreaks.com/topic/241926-seperate-at/#findComment-1242427 Share on other sites More sharing options...
requinix Posted July 13, 2011 Share Posted July 13, 2011 With that out of the way, there's also list($artist, $title) = explode(" - ", $songtitle . " - "); echo "Artist: {$artist} Title: {$title}"; Link to comment https://forums.phpfreaks.com/topic/241926-seperate-at/#findComment-1242441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.