-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathword_to_digit.php
44 lines (43 loc) · 1.01 KB
/
word_to_digit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
$fh = fopen($argv[1], "r");
while (!feof($fh)) {
$test = fgets($fh);
$arr = explode(';',$test);
$output = '';
foreach($arr as $value){
switch(trim($value)){
case 'zero':
$output .= '0';
break;
case 'one':
$output .= '1';
break;
case 'two':
$output .= '2';
break;
case 'three':
$output .= '3';
break;
case 'four':
$output .= '4';
break;
case 'five':
$output .= '5';
break;
case 'six':
$output .= '6';
break;
case 'seven':
$output .= '7';
break;
case 'eight':
$output .= '8';
break;
case 'nine':
$output .= '9';
break;
}
}
echo $output . "\n";
}
?>