July 11, 2017

Core PHP: Associative Arrays (4.2)

Associative Arrays

Associative arrays are arrays that use named keys that you assign to them.
There are two ways to create an associative array:
$people = array("David"=>"27", "Amy"=>"21", "John"=>"42");
// or
$people['David'] = "27";
$people['Amy'] = "21";
$people['John'] = "42";

In the first example, note the use of the => signs in assigning values to the named keys.

No comments:

Post a Comment