DEV Community 👩‍💻👨‍💻

Discussion on: The PHP for loop

Collapse
 
crux profile image
dirk lüsebrink

DON'T DO THIS!

Do NOT use for loops at all whereever possible. Much better to use foreach which gets rid of count and $i completely:

foreach($trees as $tree) {
    echo("Tree: ". $tree. "\n"); }
}
Enter fullscreen mode Exit fullscreen mode