ARRAY :- Collection of DATA
INDEXED ARRAY
$arr = array(‘Harshida’,’Parmar’,’IT’);
// Print Individual Value
//To Print the Individual Value you need to specify the Position for sure…
Echo $arr[0]; // Print Harshida
// If you want to Add the Value Then
$arr[3]=”INDIA”;
// It will automatically add the INDIA IN ARRAY $arr at position 3
// Print the whole array value… We use the print_r() Function
Print_r($arr);
In array the value has automatically assign the KEY/INDEX… Key/Index start from 0
At 0 :- Harshida, At Position 1 :- Parmar, At Position 2:- IT
ASSOCIATE ARRAY
< ? Php
$arr_asso = array(“H”=>”Harshida”,”P”=>”Parmar”,”G”=>’IT’);
print_r($arr_asso);
?>
If we want the index value other then 0,1,2,3 and so…
At that time Associate array came into the picture where INDEX VALUE GIVEN BY US
Like as you can see in the above example , the string value “Harshida” is at the Array position “H”, “Parmar” is at the Array Postion “P” and “IT” is at the Array position “G”
< ? Php
$arr_asso = array(“H”=>”Harshida”,”P”=>”Parmar”,”G”=>’IT’);
echo $arr_asso[“H”];
?>
This Going to print output at Harshida
SO REVISE “H,P,G” ARE KEY AND “Harshida, Parmar, IT” Are VALUE RELATED TO THE LEY
No comments:
Post a Comment