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
$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