Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7f97514

Browse files
committed
Adding last exercise to flow-of-control
1 parent e1fa8b2 commit 7f97514

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php declare(strict_types=1);
2+
3+
$input = readline ('Enter letter: ');
4+
5+
function phoneKeypad($letter) {
6+
7+
switch (strtoupper($letter)) {
8+
case "A":
9+
case "B":
10+
case "C":
11+
return 2;
12+
case "D":
13+
case "E":
14+
case "F":
15+
return 3;
16+
case "G":
17+
case "H":
18+
case "I":
19+
return 4;
20+
case "J":
21+
case "K":
22+
case "L":
23+
return 5;
24+
case "M":
25+
case "N":
26+
case "O":
27+
return 6;
28+
case "P":
29+
case "Q":
30+
case "R":
31+
case "S":
32+
return 7;
33+
case "T":
34+
case "U":
35+
case "V":
36+
return 8;
37+
case "W":
38+
case "X":
39+
case "Y":
40+
case "Z":
41+
return 9;
42+
default:
43+
return ' ERROR ';
44+
}
45+
}
46+
47+
echo "The sequence for keypad digits: $input is: ";
48+
for ($i = 0; $i < strlen($input); $i++) {
49+
echo phoneKeypad($input[$i]);
50+
51+
}
52+
echo "\n";
53+
54+
?>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /