banner image

What is an Array ?
An array is a special variable, which can hold more than one value at a time.

What are the types of Array ? 

- There is three types of array in php
1. Indexed Array
2. Associative Array
3. Multidimensional Array

1. Indexed array
  • Indexed array is the array simple array
  • Example : $color = array("red","green","blue");
  • Here array name is color and array consist of types of color  
  • Here array of zero index is red , array of  first index is green and similary array of second index is blue. this how we know it has a indexed array
2.  Associative Array

  • Associative array is the array consist of key and value known as associative array
  • Example : $user = array("firstname"=>"Mahesh","lastname"=>kannoli,"city"=>"Mumbai");
  • Here firstname is considered as key  and Mahesh is value.

3. Multidimensional arrays
  • An array consist of more than one array is known as multidimensional array
  • Example : $user = array("0"=>array("firstname"=>"Mahesh","lastname"=>kannoli),
                                           "1"=>array("firstname"=>"John","lastname"=>Bosco),                                                   "2"=>array("firstname"=>"Greg","lastname"=>Thomas)                                        ); 
  • Array under array is multidimensional

Reviewed by Admin on May 02, 2020 Rating: 5

No comments:

Powered by Blogger.