使用关联数组将ISO 3166-1 alpha-2代码转换为电话代码的功能

I am writing a php function to convert ISO 3166-1 alpha 2 codes into the country telephone code. My challenge is that when I call the function, just the + symbol shows up. How do I get the numbers too to show up? Below is the code i used, just that I've reduced the number of countries.

<?php

function ctryarray($data)
{
 $redata = "";

$country['AF'] = "+93";
$country['AL'] = "+355";
$country['DZ'] = "+213";
$country['AS'] = "+1";

$redata = $country[$data];
return $redata;

}
?>

//Then I use the following code to call it:

$countrycode = ctryarray($ccode);

where $ccode is the ISO 3166-1 alpha-2 code.

While the code you provided doesn't show the error your describe, it could probably be condensed a bit, and it should also have some error-checking:

function ctryarray($data) {
  $country['AF'] = "+93";
  $country['AL'] = "+355";
  $country['DZ'] = "+213";
  $country['AS'] = "+1";

  if (array_key_exists($data,$country)) {
    return $country[$data];
  } else {
    return false;
  }
}