PHP Arryas

There are two basic kinds of arrays in PHP - indexed and associative. Indexed are numerically indexed starting from 0. Associative arrays associate keys to their values and are indexed by thier keys.

The following are examples of two associative arrays, $a, $b defined followed by a numerically index array, $c.

$a = array("a" => "apple", "b" => "banana");
$b = array("a" => "pear", "b" => "strawberry", "c" => "cherry"); $c = array("apple", "banana"); $a['b'] //will have the value banana $c[1] //will have the value of banana
© Lynne Grewe