Use foreach instead of while, list and each. Foreach is:
- easier to read
- faster
- not influenced by the array pointer, so it does not need reset().
It works like this:
<?php
$arr = array('foo', 'bar');
foreach ($arr as $value) {
echo "The value is $value.";
}
$arr = array('key' => 'value', 'foo' => 'bar');
foreach ($arr as $key => $value) {
echo "Key: $key, value: $value";
}
?>