$a= array("Three", "two", "Four", "five","ten");
while (list ($key, $val) = each ($a)) {
echo "$key -> $val
<br>";
}
$a= array("Three", "two", "Four", "five","ten");
$max=sizeof($a);
for($i=0; $i<$max; $i++) {
echo "$a[$i] ,";
}
$a= array("Three", "two", "Four", "five","ten");
echo $a[2]; // Output is Four
Using Key
$mark=array("John"=>85,"Raju"=>75,"Alex"=>48,"Ronald"=>52);
echo $mark[Alex]; // Output is 48
$a= array("Three", "two", "Four", "five","ten");
print_r($a);
The output of the above code is here.
Array ( [0] => Three [1] => two [2] => Four [3] => five [4] => ten )
Same way here is one more array
$ar=array("FName"=>"John","Address"=>"Streen No 11 ","City"=>"Rain Town","Country"=>"USA");
print_r($ar);
The output is here
Array ( [FName] => John [Address] => Streen No 11 [City] => Rain Town [Country] => USA )
There are other way like using foreach function to display the elements of an array
Pankaj | 28-01-2013 |
how to get only key and key => values of Multidimensional Arrays ? like this way 1=>a,2=>b,3=>c answer= 1,2,3 and another one 1-A=>1,2,3 2-B=>1,2 means here a1 is array then A is also array under 1 and 1,3,2 is value of A. so i want this like that way. |