PHP Associative Arrays

PHP associate array is used to access the elements with keys by “=>”
symbol.

There are two ways to create an associative array.

1st way:

2nd way:

$age[‘john’] = “20”;

$age[‘Helena’] = “30”;

$age[‘Rasmus’] = “29”;

Let us take an example:

Example1:

Example2

Output

Key: John Value: 20
Key: Helena Value: 30
Key: Rasmus Value: 29

Leave a Comment