Current location: Hot Scripts Forums » Programming Languages » PHP » adding <BR> to the out put of a php form


adding <BR> to the out put of a php form

Reply
  #1 (permalink)  
Old 03-28-06, 12:06 PM
pkcidstudio's Avatar
pkcidstudio pkcidstudio is offline
Coding Addict
 
Join Date: Nov 2005
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
adding <BR> to the out put of a php form

i checked the search area and didnt come up with anything. i know this is somethign that one of you knows off the top of your head.
with php how to imput line breaks in a result form that gets sent.
if we wanted to do it in html it would look like this
"bla bla la
<br />
bla la la"
how is it done in php
Reply With Quote
  #2 (permalink)  
Old 03-28-06, 12:35 PM
gorivo's Avatar
gorivo gorivo is offline
Newbie Coder
 
Join Date: Mar 2006
Location: Lithuania
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
if i understood you correctly, this will help:

PHP Code:

<?php


echo "one line\n";
echo 
"another one";

?>
Reply With Quote
  #3 (permalink)  
Old 03-28-06, 01:11 PM
Barnz1986 Barnz1986 is offline
Aspiring Coder
 
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by pkcidstudio
i checked the search area and didnt come up with anything. i know this is somethign that one of you knows off the top of your head.
with php how to imput line breaks in a result form that gets sent.
if we wanted to do it in html it would look like this
"bla bla la
<br />
bla la la"
how is it done in php
Like you say it is done using <br /> in HTML the same is correct for PHP.

echo("The line breaks <br /> here");

That will result in your page looking like

The line breaks
here

However when viewing the source of the outputted HTML it will look like.

The line breaks <br /> here

If you want to add a line break in the outputted source its.

The line breaks \n <br /> here

Which will result in the source looking like this

The line breaks
<br /> here
Reply With Quote
  #4 (permalink)  
Old 03-28-06, 02:35 PM
Patiek Patiek is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
You can convert newlines found in form data to html line breaks as follows with the nl2br() function:

PHP Code:

<?php

// your form data which you are probably getting from $_POST or $_GET or $_REQUEST.
$form_data "something\nSomething else";

echo 
nl2br($form_data);
?>
Will output:
Code:
something<br />
Something else
Reply With Quote
  #5 (permalink)  
Old 03-28-06, 03:55 PM
pkcidstudio's Avatar
pkcidstudio pkcidstudio is offline
Coding Addict
 
Join Date: Nov 2005
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
any one ever tell you guys. YOU ROCKS!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
PHP Programmer - Form Metic Job Offers & Assistance 13 06-29-06 07:03 AM
Simple order PHP form to Email wearetwo PHP 8 01-06-06 03:33 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
Adding to an existing PHP script to drop form info into an Excel ss jerryh0707 PHP 1 07-21-04 03:03 PM


All times are GMT -5. The time now is 07:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.