English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Explain Indexed array and Associate array in PHP.

Advertisements
Advertisements

Question

Explain Indexed array and Associate array in PHP.

Answer in Brief
Advertisements

Solution

  • Indexed Arrays:
    Arrays with a 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. nstead of having storing data in a, linear array, with associative arrays you can store your data.
    Example:
    <?php
    $Marks=array(“Student1”=>“35”,“Student2”==>“17”,“Student3”=>“43”);
    echo “Student1 mark is” . $Marks[‘Student1’]. “ is eligible for qualification”;
    echo “Student2 mark is” . $Marks[‘Student2’]. “ is not eligible for qualification”;
    ?>
shaalaa.com
  Is there an error in this question or solution?
Chapter 5: PHP Function and Array - Evaluation - PART – IV [Page 104]

APPEARS IN

Samacheer Kalvi Computer Applications [English] Class 12 TN Board
Chapter 5 PHP Function and Array
Evaluation - PART – IV | Q 5. | Page 104
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×