Display Country Flag in Profile WordPress/Buddypress

It sounds like you are trying to use those location values for something they were not intended for, so you need to convert the values somehow.

You can rename your .gifs to match the location value then you could do…

if( !empty($korea) ) {
    echo '<img src="http://www.mydomain.com/flags/'.$korea.'.gif" border=0>';
}

Please note the change I made to your code. You had if( $korea == 'korea' );. That ; ended the line so your conditional did nothing. Your code is broken. That img always echoes. (And I added brackets. Bracket-less conditionals will trip you up.)

The other thing you could do is “map” the location value to a country. That is, build an array…

 $countries = array(
   'KR' => 'Korea',
   // ...
 }

Then use that to grab your .gifs.

function convert_location_wpse_99541($location) {
  $countries = array(
   'Korea' => 'KR',
   // ...
  }
  if (isset($counties[$location])) {
   return $counties[$location];
  }
}
// ...
$gif = convert_location_wpse_99541($korea)
if( !empty($gif) ) {
    echo '<img src="http://www.mydomain.com/flags/'.$gif.'.gif" border=0>';
}