$number = array(1,2,3,4); foreach ($number as $key => $value) { echo "Value is $value
"; } echo "
"; $num[0] = "One"; $num[1] = "Two"; $num[2] = "Three"; $num[3] = "Four"; $num[4] = "Five"; $num[5] = "Six"; foreach ($num as $key => $value) { echo "$key... $value
"; }
Result
Value is 1$sal = array("A" => 5000, "B" => 4000, "C" => 3500); echo $sal['A'];5000
$marks = array ( "Satbir" => array ( "Math" => 100, "Science" => 90, "Punjabi" => 95 ), "Kuldip" => array ( "Math" => 90, "Science" => 40, "Punjabi" => 90 ), "Iqbal" => array ( "Math" => 70, "Science" => 50, "Punjabi" => 60 ) ); echo($marks['Satbir']['Math']); var_dump($marks['Satbir']);100array(3) { ["Math"]=> int(100) ["Science"]=> int(90) ["Punjabi"]=> int(95) }