1

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) {
...
}

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.