I'm trying to write a script that shows every value in array keys using switch statement here's my simple code:
<?php
$char = array('A'=>'01', 'B'=>'02', 'C'=>'03', 'D'=>null);
foreach($char as $letter => $number)
{
switch($char[$letter])
{
case 'A':
echo $number;
break;
case 'B':
echo $number;
break;
case 'C':
echo $number;
break;
case 'D':
echo $number;
break;
default:
echo 'LETTER '.$letter.' is empty';
}
}
?>
PROBLEM:
It won't print the values that has been stored in the array.
EXPECTED OUTPUT:
if A exist return 01 . . . . . . . and so on. But if the array key contains an empty value it returns 'LETTER D is empty'
any help please? thank you