PHP Associative Array Example

Store key-value pairs in associative arrays. Edit the code below and press Run to execute it with real PHP in your browser.

Code Editor
Output
Name: John Doe
name => John Doe
age => 30
city => Boston
bool(false)

How this associative array example works

Associative arrays use string keys. Read and write values with $array["key"], delete them with unset(), and check for a key with array_key_exists() or isset() (which also returns false when the value is null).