Array Examples

Creation by assignment

Array ( [0] => 1 [1] => 2 [5] => 3 )

Creation using the array function

Array ( [0] => 25 [1] => 71 [2] => 36 [3] => 89 [4] => 40 )
Array ( [Joe] => C [Sam] => A [Alice] => B )

Adding elements

Array ( [0] => 25 [1] => 71 [2] => 36 [3] => 89 [4] => 40 [10] => 55 )
Array ( [Joe] => C [Sam] => A [Alice] => B [Fred] => B [Sally] => C )

Traversing arrays

Numbers

Grades

Sorting arrays

Sorted Numbers

Sorted Grades (by grade)

Sorted Grades (by name)