Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   New Line in PHP (http://www.go4expert.com/forums/line-php-t18532/)

naimish 14Jul2009 10:03

New Line in PHP
 
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 14Jul2009 10:12

Re: New Line in PHP
 
Use <br /> if you use an HTML output

naimish 14Jul2009 10:31

Re: New Line in PHP
 
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 14Jul2009 10:32

Re: New Line in PHP
 
Code:

fputs($file, "$name $email");
What needs to put in between $name and $email to get $email printed on next line ?

shabbir 14Jul2009 10:34

Re: New Line in PHP
 
Quote:

Originally Posted by naimish (Post 52467)
Code:

fputs($file, "$name $email");
What needs to put in between $name and $email to get $email printed on next line ?

<br />

naimish 14Jul2009 10:40

Re: New Line in PHP
 
Code:

<br />
Thanks a lot Shabbir, I got it done through it.

msn90 6Aug2009 17:10

Re: New Line in PHP
 
Thanks for this post. it is very helpful.

Seema786 6Aug2009 22:50

Re: New Line in PHP
 
stranger that <br /> is working in php too.

Saket 7Aug2009 20:47

Re: New Line in PHP
 
yeah we can use <br/> in php. just like html ;)

pradeep 8Aug2009 12:21

Re: New Line in PHP
 
You may also use this very handy PHP function nl2br http://us3.php.net/manual/en/function.nl2br.php


All times are GMT +5.5. The time now is 15:14.