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
The idea is to use str_replace()
<?php
$text = "Hello \nwelcome to \ngeeksforgeeks" ;
echo $text ;
echo "\n" ;
$text = str_replace ( "\n" , "" , $text );
echo $text ;
?>
|
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
20 Oct, 2018
Like Article
Save Article