-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfor.php
More file actions
30 lines (29 loc) · 686 Bytes
/
for.php
File metadata and controls
30 lines (29 loc) · 686 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
<?php
echo "Pick a starting number\n";
//user start input
$userStart = trim(fgets(STDIN));
if(!is_numeric($userStart)){
echo "this is not a number\n";
//default start
$userStart = 2;
}
//user end input
echo"Pick an ending number\n";
$userEnd = trim(fgets(STDIN));
if(!is_numeric($userEnd)){
echo "this is not a number\n";
//default end
$userEnd = 100;
}
//increment count
echo "Count by increments of what? \n";
$userCount = trim(fgets(STDIN));
if(!is_numeric($userCount)){
echo "this is not a number\n";
//default increment
$userCount=1;
}
//for loop
for ($a = $userStart; $a <= $userEnd; $a+=$userCount){
echo "Your number is {$a}\n";
}