EasyBasicsNot started

Platform announcement

A small railway station shows one line per departure on its display board. Read the platform number and the destination from input and print the announcement exactly as the board shows it: the word Platform, the number, a colon, then train to and the destination. For platform 3 and destination Wexley the line is Platform 3: train to Wexley.

Input

Two lines. The first is the platform number, an integer from 1 to 30. The second is the destination: 1 to 40 printable characters, which may include spaces.

Output

One line: Platform <number>: train to <destination>.

Example 1

Input

3
Wexley

Output

Platform 3: train to Wexley

The platform number and the destination are dropped into the fixed sentence.

Example 2

Input

12
Ashford Mill

Output

Platform 12: train to Ashford Mill

The destination keeps its internal space; only the newline at the end of each input line is removed.

Constraints

  • 1 <= platform <= 30
  • The destination has 1 to 40 characters and no leading or trailing spaces

Hints

Hint 1 of 3

fgets(STDIN) returns the whole line including its newline; trim() removes it.

Hint 2 of 3

Inside double quotes PHP replaces $platform with the variable's value, so the whole line can be one string.

Hint 3 of 3

echo "Platform $platform: train to $destination\n"; is the entire answer once both lines are read.

Solution

Show a reference solution and explanation
 PHP · reference solution
<?php
$platform = trim(fgets(STDIN));
$destination = trim(fgets(STDIN));
echo "Platform $platform: train to $destination\n";

Why it works

fgets(STDIN) reads one line of input as a string, newline included, which is why trim() matters: without it the colon and the rest of the sentence would land on the next line. PHP has two ways to build the output. Concatenation with . joins pieces explicitly; interpolation inside a double-quoted string lets you write the sentence naturally with variables inside it. Single-quoted strings do not interpolate, so 'Platform $platform' would print the dollar sign and the name literally.

Lesson for this exercise: PHP Syntax and Your First Program

Your program
<?php
$platform = trim(fgets(STDIN));
$destination = trim(fgets(STDIN));
// print the announcement line here
Run is not available for PHP in the browser yet. Write your program here, then download it and run it locally with PHP 8.4 against the examples above. The reference solution below was verified the same way.

Tests: 4 cases including the examples. Passing every test marks the exercise solved in this browser.

How this page was checked. Every program on it was run with PHP 8.4 at build time by the publishing checks, and the output shown is what it printed. Running PHP inside the browser is not available yet, so the Run button is absent rather than pretending; copy the code and run it with PHP 8.4 locally.