Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Associative Arrays | Arrays
Introduction to PHP
course content

Conteúdo do Curso

Introduction to PHP

Introduction to PHP

1. First Acquaintance
2. Variables and Data Types
3. Conditional Statements
4. Arrays
5. Loops

Associative Arrays

Associative arrays in PHP are arrays that provide a mapping between keys and values. They are used to store data in the form of key-value pairs, where each key is unique and associated with a specific value.

Creation Syntax


Associative arrays are created using the key operator => to establish the relationship between the key and the value. For example:

php

main

As a result, this code creates an associative array $user with three keys: "name", "age", and "city", and their corresponding values: "John", 30, and "New York". You can access these values using their respective keys:

php

main

Tarefa

Fill in the blanks in the code to create an associative array $person with three key-value pairs (e.g., 'name' => 'John', 'age' => 25, 'profession' => 'Engineer'). Then, access the value by the key 'name' and print it to the screen.

Tarefa

Fill in the blanks in the code to create an associative array $person with three key-value pairs (e.g., 'name' => 'John', 'age' => 25, 'profession' => 'Engineer'). Then, access the value by the key 'name' and print it to the screen.

Tudo estava claro?

Seção 4. Capítulo 3
toggle bottom row

Associative Arrays

Associative arrays in PHP are arrays that provide a mapping between keys and values. They are used to store data in the form of key-value pairs, where each key is unique and associated with a specific value.

Creation Syntax


Associative arrays are created using the key operator => to establish the relationship between the key and the value. For example:

php

main

As a result, this code creates an associative array $user with three keys: "name", "age", and "city", and their corresponding values: "John", 30, and "New York". You can access these values using their respective keys:

php

main

Tarefa

Fill in the blanks in the code to create an associative array $person with three key-value pairs (e.g., 'name' => 'John', 'age' => 25, 'profession' => 'Engineer'). Then, access the value by the key 'name' and print it to the screen.

Tarefa

Fill in the blanks in the code to create an associative array $person with three key-value pairs (e.g., 'name' => 'John', 'age' => 25, 'profession' => 'Engineer'). Then, access the value by the key 'name' and print it to the screen.

Tudo estava claro?

Seção 4. Capítulo 3
toggle bottom row

Associative Arrays

Associative arrays in PHP are arrays that provide a mapping between keys and values. They are used to store data in the form of key-value pairs, where each key is unique and associated with a specific value.

Creation Syntax


Associative arrays are created using the key operator => to establish the relationship between the key and the value. For example:

php

main

As a result, this code creates an associative array $user with three keys: "name", "age", and "city", and their corresponding values: "John", 30, and "New York". You can access these values using their respective keys:

php

main

Tarefa

Fill in the blanks in the code to create an associative array $person with three key-value pairs (e.g., 'name' => 'John', 'age' => 25, 'profession' => 'Engineer'). Then, access the value by the key 'name' and print it to the screen.

Tarefa

Fill in the blanks in the code to create an associative array $person with three key-value pairs (e.g., 'name' => 'John', 'age' => 25, 'profession' => 'Engineer'). Then, access the value by the key 'name' and print it to the screen.

Tudo estava claro?

Associative arrays in PHP are arrays that provide a mapping between keys and values. They are used to store data in the form of key-value pairs, where each key is unique and associated with a specific value.

Creation Syntax


Associative arrays are created using the key operator => to establish the relationship between the key and the value. For example:

php

main

As a result, this code creates an associative array $user with three keys: "name", "age", and "city", and their corresponding values: "John", 30, and "New York". You can access these values using their respective keys:

php

main

Tarefa

Fill in the blanks in the code to create an associative array $person with three key-value pairs (e.g., 'name' => 'John', 'age' => 25, 'profession' => 'Engineer'). Then, access the value by the key 'name' and print it to the screen.

Seção 4. Capítulo 3
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt