1
0
mirror of https://github.com/jupeter/clean-code-php.git synced 2025-09-26 05:59:04 +02:00

Merge pull request #20 from peter-gribanov/mental_mapping

[Bugfix] Correct use foreach
This commit is contained in:
Piotr Plenik
2017-08-29 22:11:19 +02:00
committed by GitHub

View File

@@ -108,7 +108,7 @@ Explicit is better than implicit.
```php
$l = ['Austin', 'New York', 'San Francisco'];
foreach($i=0; $i<count($l); $i++) {
for ($i = 0; $i < count($l); $i++) {
$li = $l[$i];
oStuff();
doSomeOtherStuff();
@@ -124,9 +124,7 @@ foreach($i=0; $i<count($l); $i++) {
```php
$locations = ['Austin', 'New York', 'San Francisco'];
foreach($i=0; $i<count($locations); $i++) {
$location = $locations[$i];
foreach ($locations as $location) {
doStuff();
doSomeOtherStuff();
// ...