[Solved] Display Numbers and replace with letter [closed]


Instead of having a bunch of ifs, try making a map of numbers to letters.

$map = array(
    1 => 'A',
    5 => 'B',
    9 => 'C'
);
for($i=1; $i <= 10; $i++){
    // If the value is in the map, print the letter,
    // otherwise print the number
    echo array_key_exists($i, $map) ? $map[$i] : $i;
}

0

solved Display Numbers and replace with letter [closed]