I just figured it out. I didn’t understand associative arrays properly and after doing more research I came up with the following that works:
$user_id = 6 ;
$user_meta_array = array() ;
/* the following WordPress function outputs an associative array */
$user_meta_array = get_user_meta($user_id);
$meta_cnt = -1 ;
/* You need the following loop structure to output nicely */
foreach($user_meta_array as $user_meta =>$mk)
{
$meta_cnt = $meta_cnt + 1 ;
echo('Meta Key: '.$user_meta.'<br/>');
/* Each wp_usermeta key can have multiple values */
$meta_vals_found = false ;
foreach($mk as $mk_each)
{
if(!empty($mk_each))
{
$meta_vals_found = true ;
echo('Meta Value----> '.$mk_each.'<br/>');
}
}
if(!$meta_vals_found)
{
echo('----> No Meta Values Entered<br/>');
}
}