I am working on using jplayer html5 audio playlist
I use foreach to create a script item for each playlist item. Everything works as expected, except that I included the comma in the loop, but I need a way to write the comma as a separator, with the exception of the last element.
here is what i have to create a jplayer playlist.
<?php foreach( $songs as $song ): if( !empty($song) ): ?>{
title:"Each Song Title",
mp3:"Each song mp3 url"
},<?php endif; endforeach; ?>
which gives me
{
title:"Partir",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-09-Partir.mp3"
},
{
title:"Thin Ice",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-10-Thin-ice.mp3"
},
{
title:"Ice man",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-10-Thin-ice.mp3"
},
This is my desired result.
{
title:"Partir",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-09-Partir.mp3"
},
{
title:"Thin Ice",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-10-Thin-ice.mp3"
},
{
title:"Ice man",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-10-Thin-ice.mp3"
}
Can someone point me in the right direction?
source
share