Associative array initialization:
<?PHP $arr = array("one"=>"Monday","two"=>"Tuesday","three"=>"Wednesday", "four"=>"Thursday","five"=>"Friday","six"=>"Saturday","seven"=>"Sunday"); ?>
Initialize element by element and count the length of the array:
<?PHP $arr = array(); $arr["one"] = "Monday"; $arr["two"] = "Tuesday"; $arr["three"] = "Wednesday"; $arr["four"] = "Thursday"; $arr["five"] = "Friday"; $arr["six"] = "Saturday"; $arr["seven"] = "Sunday"; echo count($arr); //7 ?>
Iterate through the associative array:
<?PHP foreach($arr as $num=>$d) { echo "$num, $d\n"; } ?>
Associative array can also be iterated by
<?PHP while (list($key,$value) = each($arr)) { echo "$key, $value\n"; } ?>