Friday, April 5, 2013

PHP Array -> Enumerated Arrays

What is Array in PHP?
Array is a data type that store number of data in single variable. For example, you want to store all the countries in single variable, for this you will keep data type as array.

See in example below:
$countries = array('IN','PAK','AUS','US');

Enumerated Array: It is variable whose datatype is array and keys are number of that array. Following are 3 example of enumerated Array.
$countries1 = array('IN','PAK','AUS','US');
$countries2 = array(
  0=>'IN',
  2=>'PAK',
  3=>'AUS',
  4=>'US'
  );
  
  $countries2 = array(
  2=>'IN',
  34=>'PAK',
  5=>'AUS',
  6=>'US'
  );

No comments:

Post a Comment