First, create an array containing all your data, using the letters as keys:
PHP Code:
$STACK = array(
'A' => 'Alpha',
'B' => 'Bravo',
'C' => 'Charlie',
'D' => 'Delta',
'E' => 'Echo',
'F' => 'Foxtrot',
'G' => 'Golf',
'H' => 'Hotel',
'I' => 'India',
'J' => 'Juliet',
'K' => 'Kilo',
'L' => 'Lima',
'M' => 'Mike',
'N' => 'November',
'O' => 'October',
'P' => 'Papa',
'Q' => 'Quebec',
'R' => 'Romeo',
'S' => 'Sierra',
'T' => 'Tango',
'U' => 'Uniform',
'V' => 'Victor',
'W' => 'Whiskey',
'X' => 'X-ray',
'Y' => 'Yankee',
'Z' => 'Zulu',
);
function something() {
global $STACK;
$result = "";
// some form of input controlled loop to gather all characters, maybe?
// Truncate the POST string to only the first alpha character, case insensitive.
// regex and replace leading spaces and non-alpha characters with ""
$var = preg_replace("/[^a-z]/i", "", $var);
// first character and force it into uppercase
$var = strtoupper(substr($var, 0, 1));
// Now traverse your index for a match and return the callout:
$result .= alphaToCallout($var) . ", ";
// get another character, keeping $result alive
.
.
.
};
function alphaToCallout($post) {
global $STACK;
foreach ($STACK as $alpha => $callout) {
if ($post == $key) return $callout;
};
};
Not tested, so might need tweaking. Let us know if this helps.