Color theme
0 day streak0 XPP1
PHPLearn 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
LEARN THE CONCEPT

Understand it, then try it.

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.

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.

Track the values line by line. Predict the result before running this example in your own editor.