You can add another simple foreach loop to check if you have any values first:
foreach ( $meta_boxes as $metabox ) {
$has_value = false
foreach ( $metabox['fields'] as $field ) {
$meta = get_post_meta($post->ID, $field['id'], true);
if(!isset($meta[0])){
$need_title = true;
break;
}
}
if ($has_value){
echo $metabox['title'];
foreach ( $metabox['fields'] as $field ) {
$meta = get_post_meta($post->ID, $field['id'], true); //get post meta from each metabox
if(!isset($meta[0])) continue; //display only fields with values
echo $field['name'];
echo $meta ? $meta : $field['std']; //show value or default value
}
}
}