Web >> Development >> PHP >>  How to loop through a "perl hash"-like array

$a = array( "one" => 1, "two" => 2, "three" => 3, "seventeen" => 17 ); foreach ($a as $k => $v) { echo "$a[$k] => $v.\n"; } OR foreach ( array_keys($a) as $k ) { print "$a[$k] = " . $a[$k] . "\n"; }