Let see an example: Suppose I want to store the quatity of fruits in a shop in an array. For this I will
create an array like this:
Code: Select all
$fruits = array();
$fruits['apple'] = 120;
$fruits['orange'] = 60;
$fruits['pear'] = 220;
Code: Select all
echo " Count of orange is ".$fruits['orange'];
echo " Count of apple is ".$fruits['apple'];
echo " Count of pear is ".$fruits['pear'];
Code: Select all
echo " Count of Lemon is ".$fruits['lemon'];
Similarly php will again throw undefined notice if you try to display $fruits['99'];