Color theme
0 day streak0 XPP1
PHPLearn mode
MISSION 1 OF 1

Personalize a theater notice

0 XP earned
PHP track: IntermediateMission: BeginnerString replacementFunction argumentsReturn values
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 / 2 challenges
LEARN THE CONCEPT

Understand it, then try it.

A theater notice repeats the same seat placeholder in two places. str_replace takes the text to find, its replacement, and the original string, in that order. It returns a new string with every matching occurrence replaced. Keeping that result in notice makes the finished wording available for printing.

quest.php
<?php$template = "Seat {seat}; keep stub for {seat}.";$notice = str_replace("{seat}", "B12", $template);echo $notice, "\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.