$word[0]="a"; $word[1]="the"; $word[2]="this"; $mark["ann"]=100; $mark["bob"]=50; $mark["col"]=9; $vec[]=1; $vec[]=3; $vec[]=5; $vec[]=7; $vec[] = 9; // which is equivalent to $vec[0]=1; $vec[1]=3; $vec[2]=5; $vec[3]=7; $vec[4] = 9;
Arrays can be initialised in a single statement:
$word = array("a", "the", "this"); $marks = array("ann"=>100, "bob"=>50, "col"=>9); $vec = array(0 => 1, 1 => 3, 2 => 5, 3 => 7, 4 => 9); // which is equivalent to $vec = array(1, 3, 5, 7, 9);