By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy

Q: Chars to String - PHP Task

+4 votes

Write a program that reads 3 lines of input. On each line you get a single character. Combine all the characters into one string and print it on the console.


chars to string php task

asked in PHP category by user eiorgert

2 Answers

+3 votes



$input1 = readline();
$input2 = readline();
$input3 = readline();

echo $input1 . $input2 . $input3;
answered by user john7
+1 vote

Another solution:


$result = '';
for ($i = 0; $i < 3; $i++) {
    $input = readline();
    $result .= $input;

echo $result;
answered by user nikole