Commit 709d387 Adrian Reimann
committed
1 parent 870861d commit 709d387 Copy full SHA for 709d387
File tree 3 files changed +5
-10
lines changed
3 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,8 @@ function markBoard(&$board, $number) {
53
53
}
54
54
55
55
//after we've replaced all numbers of the board, check the columns (we already checked rows when going per row)
56
- $ i = 0 ;
57
- while ($ i < 5 ) { //loop through columns up to 5 (cannot use count($row) as some rows may have gotten shorter)
58
- $ column = array_column ($ board , $ i ++);
56
+ for ($ i = 0 ; $ i < 5 ; $ i ++) { //loop through columns up to 5 (cannot use count($row) as some rows may have gotten shorter)
57
+ $ column = array_column ($ board , $ i );
59
58
if (array_sum ($ column ) == 0 ) {
60
59
return true ; //winner by column!
61
60
}
Original file line number Diff line number Diff line change @@ -62,9 +62,8 @@ function markBoard(&$board, $number) {
62
62
}
63
63
64
64
//after we've replaced all numbers of the board, check the columns (we already checked rows when going per row)
65
- $ i = 0 ;
66
- while ($ i < 5 ) { //loop through columns up to 5 (cannot use count($row) as some rows may have gotten shorter)
67
- $ column = array_column ($ board , $ i ++);
65
+ for ($ i = 0 ; $ i < 5 ; $ i ++) { //loop through columns up to 5 (cannot use count($row) as some rows may have gotten shorter)
66
+ $ column = array_column ($ board , $ i );
68
67
if (array_sum ($ column ) == 0 ) {
69
68
return true ; //winner by column!
70
69
}
Original file line number Diff line number Diff line change @@ -171,17 +171,14 @@ function fillEmptyFields($arr, $filler = '.') {
171
171
}
172
172
173
173
//fill every row of the array with the "empty" filler
174
- $ i = 0 ;
175
174
$ full_arr = [];
176
- while ($ i <= $ highest_y ) { //<= as we start from 0
175
+ for ($ i = 0 ; $ i <= $ highest_y ; $ i ++ ) { //<= as we start from 0
177
176
$ full_arr [$ i ] = array_fill (0 , $ highest_x +1 , $ filler ); //dot will be our "empty" fields (highest_x+1 as we start from 0)
178
177
179
178
//if this row exists on the array of actual values, here is the time where we replace the "empty" fields of that row with actual fields
180
179
if (isset ($ arr [$ i ])) {
181
180
$ full_arr [$ i ] = array_replace ($ full_arr [$ i ], $ arr [$ i ]);
182
181
}
183
-
184
- $ i ++;
185
182
}
186
183
187
184
//return the filled up array
You can’t perform that action at this time.
0 commit comments