You can use the implode
function to concatenate array elements:
$get_the_following_users = get_user_meta($current_user->ID, 'following_users', true);
$meta_qssuery = ''; //initialise to an empty string
foreach ( $get_the_following_users as $following_user ) {
$following_user = get_user_meta($following_user, 'following_users', true);
if(!empty($following_user)) { //check if any data was returned
$meta_qssuery .= implode(', ', $following_user).', ';
}
}
echo $meta_qssuery;
This will leave an extra ‘, ‘ at the end of the string. This can be removed after the loop ends, or you can modify the loop:
$get_the_following_users = get_user_meta($current_user->ID, 'following_users', true);
$get_the_following_users_2 = array();
foreach ( $get_the_following_users as $following_user ) {
$following_user = get_user_meta($following_user, 'following_users', true);
if(!empty($following_user)) { //check if any data was returned
$get_the_following_users_2[] = implode(', ', $following_user);
}
}
$meta_qssuery = implode(', ', $get_the_following_users_2);
echo $meta_qssuery;