1<?php
2/*
3There are 3 Types of array in php
41. Indexed arrays - Arrays with a numeric index
52. Associative arrays - Arrays with named keys
63. Multidimensional arrays - Arrays containing one or more arrays
7
8This is the second one - Associative arrays
9*/
10
11$age = array("Samy"=>"35", "Naveen"=>"37", "Amit"=>"43");
12echo "Mr.Samy is " . $age['Peter'] . " years old.";
13
14?>
1//This is the declaration of an associative array.
2$animals["firstindex"]="ape";
3$animals["secondindex"]="dinosaur";
4$animals["thirdindex"]="ahahah";
5for(reset($animals);$element=key($animals);next($animals))
6{print("$element is $animals[$element]");
7}
8
9//Can also be created by using an array function
10$fourth=array("January"=>"first","February"=>"second","March"=>"third","April"=>"fourth");
11foreach($fourth as $element=>$value)
12print("$element is the $value month");
13