I am working on incorperating the jplayer html5 audio playlist
I’m using a foreach to generate the script element for each playlist item.
Everything is working as expected, Except I’ve included the comma in the loop, but I need a way to write the comma as separator except for last item.
here is what I’ve got so far to generate 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 anyone point me in the right direction?
I use next() for it: