File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 11
11
echo $ i . PHP_EOL ;
12
12
}
13
13
}
14
- ?>
14
+ ?>
Original file line number Diff line number Diff line change @@ -14,17 +14,16 @@ function list_items($list) {
14
14
$ place = '' ;
15
15
// Iterate through list items
16
16
foreach ($ list as $ key => $ item ) {
17
- // The Ben B method: doing addition first and output second helps the brain split the process
18
- $ key ++; //$key = $key + 1
19
- $ place .= "[ " . $ key . "] " . " " . $ item . PHP_EOL ;
17
+ $ newKey = $ key + 1 ;
18
+ $ place .= "[ " . $ newKey . "] " . " " . $ item . PHP_EOL ;
20
19
// Display each item and a newline
21
20
}
22
21
return $ place ;
23
22
}
24
23
25
24
// Get STDIN, strip whitespace and newlines,
26
25
// and convert to uppercase if $upper is true
27
- function get_input ($ upper = FALSE ) {
26
+ function get_input ($ upper = false ) {
28
27
// Return filtered STDIN input
29
28
if ($ upper == TRUE ) {
30
29
return strtoupper (trim (fgets (STDIN )));
@@ -66,7 +65,7 @@ function get_input($upper = FALSE) {
66
65
// Get array key
67
66
$ key = get_input ();
68
67
// Remove from array
69
- unset($ items [-- $ key ]);
68
+ unset($ items [$ key ]);
70
69
// Adding sort input
71
70
} elseif ($ input == 'S ' ) {
72
71
// Alphabetical or Reverse alphabet?
You can’t perform that action at this time.
0 commit comments