In PHP, array() helps to creates an array, with keys and values. If you skip the keys when you specify an array, an integer key is generated, key index starting at 0 and increases by 1 for each value.
Syntax :
array(key => value)
<?php
$employeeIDs = array(101,102,103,104);
print_r($employeeIDs);
?>
Output : Array ( [0] => 101 [1] => 102 [2] => 103 [3] => 104 )
<?php
$employeeNames = array(101=>’name1′,102=>’name2′,103=>’name3′,104=>’name4′);
print_r($employeeNames);
?>
Output : Array ( [101] => name1 [102] => name2 [103] => name3 [104] => name4 )
<?php
$employeeNames[101]=’name1′;
$employeeNames[102]=’name2′;
$employeeNames[103]=’name3′;
$employeeNames[104]=’name4′;
print_r($employeeNames);
?>
Output : Array ( [101] => name1 [102] => name2 [103] => name3 [104] => name4 )