Skip to content

Commit 08d73d6

Browse files
correct use foreach
1 parent 58ba5d1 commit 08d73d6

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Explicit is better than implicit.
108108
```php
109109
$l = ['Austin', 'New York', 'San Francisco'];
110110

111-
foreach($i=0; $i<count($l); $i++) {
111+
for ($i = 0; $i < count($l); $i++) {
112112
$li = $l[$i];
113113
oStuff();
114114
doSomeOtherStuff();
@@ -124,9 +124,7 @@ foreach($i=0; $i<count($l); $i++) {
124124
```php
125125
$locations = ['Austin', 'New York', 'San Francisco'];
126126

127-
foreach($i=0; $i<count($locations); $i++) {
128-
$location = $locations[$i];
129-
127+
foreach ($locations as $location) {
130128
doStuff();
131129
doSomeOtherStuff();
132130
// ...

0 commit comments

Comments
 (0)