![]() |
VOOZH | about |
Given a multiple line sentence or statement the task is to convert the whole statement in a single line. See the example below. Examples:
Input : Hello
welcome to geeksforgeeks.
Output : Hello welcome to geeksforgeeks.
Remove the new line between Hello and geeksforgeeks.
Input : I
love
geeksforgeeks
Output : I love geeksforgeeks
Here are some common approaches
You can use str_replace in PHP to replace newline characters with spaces or simply remove them to concatenate multiple lines into a single line.
Example:
Hello welcome to geeksforgeeks Hello welcome to geeksforgeeks
You can use preg_replace() in PHP to replace newline characters with spaces or simply remove them to concatenate multiple lines into a single line.
Example:
I love geeksforgeeks
The explode() function splits a string by a specified delimiter, and the implode() function joins array elements into a single string using a specified delimiter.
Example
Hello welcome to geeksforgeeks. I love geeksforgeeks