I am looking to take the next step on my switch statement. I need to keep both pieces of information generated from the case statement (knowing whether the letter is a vowel and knowing it's numeric value). I then need to add the values generated by the below function but can't figure out through research or tutorials how to do this. I have made a string that looks like an array, but I don't think that is the best way.
$firstName = strtoupper("Abc");
$firstNamesArray = str_split($firstName);
$string = "(";
foreach ($firstNamesArray as $value) {
$newValue = (getLetter($value)) . " ";
$string .=$newValue;
}
echo "<br>";
$string .=")";
echo $string;
function getLetter($letter) {
switch ($letter) :
case "A":
return '"V" => 1'; break;
case "B":
return '"C" => 2'; break;
case "C":
return '"C" => 3'; break;
default:
return 'This is not a valid selection';
endswitch;
}
I want to add the values 1 + 2 + 3 (the second part of the case return value).
I appreciate your advice/assistance!