New Line in PHP

naimish's Avatar
Banned
Please see the code below first.

Code:
 
<?php
$savedata = $_REQUEST['savefeedback'];
if ($savefeedback == 1){ 
$data = $_POST['name'];
$data .= $_POST['feedback'];
$file = "feedback.txt"; 
$fp = fopen($file, "a") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!"); 
fclose($fp); 
echo "Your Form has been Submitted!";
}
?>
Output :

NaimishYour Website is very nice.
JohnI will visit your website now.

Now What I want to do is, the output should be like this,

Naimish
Your Website is very nice.

John
I Will visit your website now.

How can I apply code for a new line in below code ?

Code:
 
 
$data = $_POST['name'];
$data .= $_POST['feedback'];
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Use <br /> if you use an HTML output
naimish's Avatar
Banned
Code:
<html dir="ltr">
    <head>
        <title></title>
        <?php
$name = $_POST['name'];
$email .= $_POST['email'];

$count = $email."/n".$name."/n";

$file = fopen("YOURDATAFILE.txt", "a");
fputs($file, "$name $email");
fclose($file);
?>
    </head>
    <body>
    </body>
</html>
Nothing working
naimish's Avatar
Banned
Code:
fputs($file, "$name $email");
What needs to put in between $name and $email to get $email printed on next line ?
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by naimish View Post
Code:
fputs($file, "$name $email");
What needs to put in between $name and $email to get $email printed on next line ?
<br />
naimish's Avatar
Banned
Code:
<br />
Thanks a lot Shabbir, I got it done through it.
msn90's Avatar, Join Date: Jul 2009
Go4Expert Member
Thanks for this post. it is very helpful.
Seema786's Avatar
Banned
stranger that <br /> is working in php too.
Saket's Avatar
Banned
yeah we can use <br/> in php. just like html
pradeep's Avatar, Join Date: Apr 2005
Team Leader
You may also use this very handy PHP function nl2br http://us3.php.net/manual/en/function.nl2br.php