PHP Array is that kind of structure where lots of value can be stored in a variable. If we want to declare a variable A to Z character. At that time we need to use PHP Array. Otherwise, we have to create single variable for every character?s, it will arrange lots of variable which one is very difficult to count such huge variable. New, if we can use all character in a variable, it will be must better for us.

  In PHP, there are three kinds of arrays:

# Numeric array - An array with a numeric index
# Associative array - An array where each ID key is associated with a value
# Multidimensional array - An array containing one or more arrays

  Since, in PHP Array variable have lots of value, so if we want to count or call variable to display that value write $student[0], $student[1], $student[3] sequencely. Here 0 is index number. Example is given below.

PHP code Numeric array :

echo $student[0];

Associative array is very important and populer array now. In Associative array lots of value can be stored in a variable.


<?php $student=array("jamal","Rahim","Hasan");
echo $student[1];  ?>

Note:According to above example $student[1]; will display Rahim.

Example of Associative Arrays

$student=array('jamal'=>'E00221', 'Rahim'=>,'E00331', 'Hasan'=>'E00421')
echo $student["Rahim"]; ?>


Note:According to above example ['Karim'] is key and "E00221" is value.

All Tutorial => 12345678910

Write Comment