Php Array

An array is a special variable, which can store multiple values in one single variable. there are three types of array in PHP.

  • Indexed array in PHP
  • Associative array in PHP
  • Multidimensional array in PHP

Indexed array in PHP

The indexed array stores a single value(numeric index value). so it is called a numeric array.


$arr = array("apple","orange");
echo count($arr); //1

Associative array in PHP

The Associative array is used to key values. each key in-store the specific values it is called Associative array.


$arr = array('id'=>1,'name'=>'john');
echo $arr['id']; //1
echo $arr['name']; //john

Multidimensional array in PHP

The Multidimensional array is one type of array. it is stored in one array in another array it is called a Multidimensional array.


$arr = array(