1
0
mirror of https://github.com/jupeter/clean-code-php.git synced 2025-10-01 08:26:41 +02:00

correct use foreach

This commit is contained in:
Peter Gribanov
2017-08-29 18:18:18 +03:00
committed by GitHub
parent 58ba5d1b00
commit 08d73d655e

View File

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