I've found a compact way to cycle through an associative array using for statement (not while, as it has been done in the most of examples below):
<?php
for (reset($array); list($key) = each($array);) {
echo $key;
echo $array[$key];
}
?>
or
<?php
for (reset($array); list($key, $value) = each($array);) {
echo $key;
echo $value;
echo $array[$key];
}
?>
You hardly forget to add reset($array) code line using such construction.