# PHP - Arrays
{id: php-arrays}

## Array
{id: array}
{i: array}

{aside}

{/aside}
![](examples/intro/array.php)


## Associative Array
{id: associative-array}
{i: hash}
{i: dictionary}

{aside}

Associative or Named Arrays are maps where the keys can be either strings or numbers.
{/aside}
![](examples/intro/associative_array.php)


## Array in key/value pairs
{id: array-pairs}
{i: foreach}
{i: as}
![](examples/intro/array_pairs.php)


## Array in key/value pairs using each
{id: array-each}
{i: each}
{i: list}
![](examples/intro/array_each.php)


## sort
{id: sort}
{i: sort}

For arrays where the keys are numbers. reorder the array

![](examples/intro/sort.php)


## asort
{id: asort}
{i: asort}
![](examples/intro/asort.php)


## ksort
{id: ksort}
{i: ksort}
![](examples/intro/ksort.php)


## Special Arrays
{id: special-arrays}
{i: _SERVER}
{i: _GET}
![](examples/intro/special_arrays.php)

* [About reserved variables](http://www.php.net/manual/en/reserved.variables.php)
* [CGI Specification](http://hoohoo.ncsa.uiuc.edu/cgi/env.html)



## The _SERVER variable
{id: server}
{i: _SERVER}

{aside}
Some of the values are server dependent!
{/aside}

![](examples/intro/all_server_variables.php)



## A simple form
{id: simple-form}
{i: _GET}
![](examples/intro/simple_form.php)


## A simple calculator
{id: simple-calculator}
![](examples/intro/simple_calculator.php)


## If statement
{id: if-statement}
{i: if}
![](examples/intro/if_statement.php)


## for loop
{id: for-loop}
{i: for}
![](examples/intro/for_loop.php)


## Exercise: improve the calculator
{id: exercise-improve-calculator}

Improve the calculator to handle more operations



## Exercise: keep values in the fields
{id: exercise-keep-values-in-the-fields}

Form with keeping the values in the fields after submit




