Search Header Logo

12. Associative Arrays in PHP

Authored by Lui Kit

Computers

12th Grade

Used 1+ times

12. Associative Arrays in PHP
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

18 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is an associative array?

An array indexed with numeric values

An array indexed with strings called keys

A graphical representation of data

A database storage method

Answer explanation

Answer: An array indexed with strings called keys

Explanation: Associative arrays use character strings (keys) to describe the content of each element, unlike standard arrays that use numeric indices.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which PHP function can be used to create associative arrays?

array()

new_array()

create_array()

set_array()

Answer explanation

Answer: array()

Explanation: The array() function, combined with the => operator, is used to create associative arrays in PHP.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a key characteristic of associative arrays?

They only store numeric data

They allow meaningful keys for elements

They are always sorted alphabetically

They are limited to database applications

Answer explanation

Answer: They allow meaningful keys for elements

Explanation: Associative arrays are useful when meaningful keys can be assigned to each array element.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which array is automatically created when a form with the method “post” is submitted?

$_SESSION

$_REQUEST

$_GET

$_POST

Answer explanation

Answer: $_POST

Explanation: The $_POST array is populated with input field values submitted via a form using the “post” method.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primary difference between $_GET and $_POST?

$_GET is secure, $_POST is not

$_GET includes data in the URL, while $_POST does not

$_POST is read-only, $_GET is editable

$_GET can handle larger data submissions than $_POST

Answer explanation

Answer: $_GET includes data in the URL, while $_POST does not

Explanation: The $_GET method sends data in the URL, making it less secure than $_POST.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code snippet?

$userList['mike'] = "123";

echo $userList['mike'];

An error

"mike"

123

null

Answer explanation

Answer: 123

Explanation: The associative array $userList stores “123” with the key 'mike'.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens when session_start() is called in PHP?

A new session ID is created

A session is resumed if one exists

Session data becomes accessible

All of the above

Answer explanation

Answer: All of the above

Explanation: The session_start() function initiates or resumes a session and makes session variables available.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?