-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfor.php
More file actions
70 lines (33 loc) · 940 Bytes
/
for.php
File metadata and controls
70 lines (33 loc) · 940 Bytes
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
echo "Hey kid! let me print you some numbres\n";
fwrite(STDOUT, "what minimum integer would you like?\n");
do {
$minNum = trim(fgets(STDIN));
if (is_numeric($minNum)) {
$minNum = (int)$minNum;
} else {
fwrite(STDOUT, "that's not a number, please enter a number\n");
}
} while (!is_int($minNum));
fwrite(STDOUT, "and how about for the maximum integer?\n");
do {
$maxNum = trim(fgets(STDIN));
if (is_numeric($maxNum)) {
$maxNum = (int)$maxNum;
} else {
fwrite(STDOUT, "that's not a number, please enter a number\n");
}
} while (!is_int($maxNum));
fwrite(STDOUT, "what incriments would you like me to count with?\n");
do {
$iNum = trim(fgets(STDIN));
if (is_numeric($iNum)) {
$iNum = (int)$iNum;
} else {
$iNum = 1;
}
} while (!is_int($iNum));
echo "\nhere come your numbers baby\n\n";
for ($i = $minNum; $i <= $maxNum ; $i= $i + $iNum) {
echo "$i\n";
}