| 1. |
Explain Indexed array and Associate array in PHP? |
|
Answer» Indexed Arrays: Arrays with numeric index for the available values in array variable which contains key value pair as user / developer can take the values using keys. Example: <?php $teacher_name=array(“Iniyan” , “Kavin” , “Nilani”); echo “The students name are “ .$teacher_name[0]. “ , “ . $$teacher_name[l]. “ and” . $teacher_name[2]. ?> Associative Arrays: 1. Associative arrays are a key-value pair data structure. 2. Instead of having storing data in a, linear array, with associative arrays you can store your data. Example: <?php $Marks=array(“Studentl” =>“35” , “Student2” ==>“17” , “Student3” =>“43”); echo “Studentl mark is” . $Marks[‘Studentl’]. “ is eligible for qualification”; echo “Student2 mark is” . $Marks[‘Student2’]. “ is not eligible for qualification”; |
|