← CodePrimer
PHP
Beginner
Basics
Associative arrays
How do I store key/value pairs?
String keys.
<?php
$user = [
'name' => 'Ada',
'email' => 'ada@example.com',
];
echo $user['email'];
Notes
Most form/database rows map naturally to associative arrays.
Keywords: associative · array · key · value
Related
HTML
HTML headings h1–h6
How do I create page headings?
CSS
Three ways to apply CSS
What are inline, internal, and external CSS?
PHP
Embed PHP inside HTML
How do I mix PHP and HTML?
HTML
Paragraphs and line breaks
How do I break text into paragraphs?
CSS
CSS box model
Why is my element wider than expected?
PHP
PHP comments
How do I write comments in PHP?