explode array within shortcode

This functions at the moment but it only returns the first value from the array. I’ve been struggling to echo, print, explode, or whatever the multiple custom field values that share the same key (mp3). The shortcode is looking for comma-separated urls aka tracks="http://url1.mp3, http:/url2.mp3"
I know i’ve created a bit of mess here. Wading into deeper waters…

<div id="post_meta_player">
<?
global $post;
if(get_post_meta($post->ID, 'mp3', false))
{
foreach(get_post_meta($post->ID, 'mp3', false) as $mp3)
    {
    $mytracks = print_r($mp3, ',');
    }
}
$shortcodes = '[mp3-jplayer tracks="'.$mytracks.'"]';
mp3j_put( $shortcodes);
?>
</div>

Related posts

Leave a Reply

1 comment

  1. Kind of confusing question, but I think you want:

    [mp3-jplayer tracks="'.implode(', ', get_post_meta($post->ID, 'mp3', false)).'"]

    Assuming you get a array of meta key values this will join the into a comma-separated string