Plus foreach values php

i want to combine all array value into one sting

$beranda = json_decode(get_html("https://graph.facebook.com/me/taggable_friends?fields=id&access_token=$accessToken"))->data;
foreach($beranda as $friendsid){
$tag[]= $friendsid->id;
$tags =+ $tag[$i++];
}

Take a look at PHP’s implode function: http://php.net/manual/en/function.implode.php


$tags = [];

foreach ($beranda as $friendsid) {
    $tags[] = $friendsid->id;
}

echo implode(', ', $tags);
1 Like

Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.