Adding elements with [] : Array Index « Data Structure « PHP






Adding elements with []

 
<?
// This sets $lunch[0]
$lunch[] = 'A';
// This sets $lunch[1]
$lunch[] = 'B';

$dinner = array('A', 'B','C');
// This sets $dinner[3]
$dinner[] = 'F';
?>
  
  








Related examples in the same category

1.Alternating table row colors
2.Setting an Array's Size
3.Getting array size
4.Loops through an indexed array of fruit names and creates a new array with the count of each fruit name.