Reputation: 919
I am viewing a block of code which implements both of the following iteration methods at the same time. I'm wondering if there is a practical difference between the two methods of iteration?
while (list($module) = each($module_list)) {
...
}
and
foreach ($module_list as $module) {
...
}
Upvotes: 1
Views: 181
Reputation: 354456
The latter is much more readable. There may be reasons to use the functions that implicitly change array cursors, but a simple iteration over all values is not such an occasion.
Upvotes: 2