Color theme
0 day streak0 XPP1
PHPQuiz mode
MISSION 1 OF 3

Update a bakery ticket

0 XP earned
PHP track: IntermediateMission: BeginnerAssociative arraysKeyed updatesArray counts
Before you start this intermediate track

Variables, function calls, and key-value arrays. These examples run as small scripts.

Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.

x
0 / 6 challenges
KNOWLEDGE CHECK

Predict the result.

What two lines are printed for the updated ticket?

quest.php
<?php$order = ["bread" => "rye", "sliced" => true];$order["bread"] = "sourdough";echo $order["bread"], "\n";echo count($order), "\n";

Each mission is a complete independent PHP 8 or later command-line script, including the opening <?php tag. Save as quest.php and run php quest.php. Output is plain text; no web server is required.

Review the lesson

A bakery ticket uses an associative array so each value has a meaningful key. Assigning through an existing key replaces that entry without adding another item. Empty brackets would append a new entry instead. count reports the number of entries, which is useful for checking whether an update changed the ticket structure.

Choose your answer+25 XP on first completion