paulmason411
Dec 7 2007, 10:10 AM
| | Hi guys,
I have set up a form with a textarea. If I have text on multiple lines such as:
CODE here is some content
here is some more content
then when I print it out as html it will be returned on one line like so:
CODE here is some contenthere is some more content
When i look at the content in the database it looks just like the original way i entered it (contains the multiple lines).
Is there a function in php so that when i spit it out in html it retains the multiple line format?
Thanks in advance.
|
Reply
jlhaslip
Dec 7 2007, 12:54 PM
try this: CODE $value = str_replace(array( "\r", "\n", "%0a", "%0d"), ' ', $value);
Reply
mahirharoon
Dec 7 2007, 02:02 PM
put \n at last of the line
Reply
paulmason411
Dec 7 2007, 02:07 PM
jlhaslip you've done it again. Thanks!
Reply
ewcreators
Dec 7 2007, 02:20 PM
QUOTE(paulmason411 @ Dec 7 2007, 10:07 AM)  jlhaslip you've done it again. Thanks! that may be sorta complex. The easiest way is to use : CODE <?php $line_break=nl2br($_POST['text']); echo $line; ?> nl2br() is a function which inserts a <br /> automatically at the end of every line.
Reply
jlhaslip
Dec 7 2007, 03:24 PM
CODE $value = str_replace(array( "\r", "\n", "%0a", "%0d"), ' ', $value); I use that in a function that replaces all the bad stuff in Emails, Comments, $_POST arrays, etc. Yes, probably a little overkill checking for the hex values. And you are correct, the nl2br() would likely do it. I had not had my morning coffee yet when I replied...
Reply
iGuest
Jun 22 2008, 03:00 AM
character count
Converting Textarea Return Characters To
Guys teach me how to post the character count on php from the html textarea. I know how to do the wordcount but the character count is really my problem Need help -reply by abby
Reply
who?
Jul 9 2008, 11:23 PM
QUOTE(FeedBacker @ Jun 22 2008, 04:00 AM)  character count
Converting Textarea Return Characters To Guys teach me how to post the character count on php from the html textarea. I know how to do the wordcount but the character count is really my problem
Need help
-reply by abby I'm not sure if I understand your problem, but try using strlen($str), where $str is the textarea value.
Reply
optiplex
Jul 21 2008, 06:13 PM
Oh thats really simple! you can replace newlines using str_replace like this CODE $your_string = str_replace(array(chr(10), chr(13)), "<br />", $your_string); or you can use nl2br CODE $your_string = nl2br($your_string); BUT if you are showing html code anyway, you can write it in a textarea like : <textarea><? echo $your_string; ?></textarea> or using the <PRE> tag, like this: <PRE><? echo $your_string; ?></PRE> But there are more options afcourse Thats it! - optiplex
Reply
gogoily
Aug 4 2008, 08:56 AM
There's a very useful function in PHP to handle this situation. The function is "nl2br()", try it and you'll find how cute PHP is
Reply
Recent Queries:--
display textarea with br in it - 1.99 hr back. (1)
-
textarea php return problem - 2.82 hr back. (1)
-
textarea return - 15.51 hr back. (1)
-
php replace chr(10) textarea - 17.21 hr back. (1)
-
converting return character - 21.17 hr back. (1)
-
textarea problem in ie - 23.48 hr back. (1)
-
return character in html - 36.91 hr back. (1)
-
return character in php - 38.92 hr back. (1)
-
textarea problem - 39.56 hr back. (1)
Similar Topics
Keywords : converting, textarea, return, characters,
- Validation Script - Detecting Illegal Characters
preg_match to find illegal characters (0)
Php Escaped Control Characters And Windows
they aren't working for me. (3) In php coding, when you escape certain characters, they have an impact on the output of an
echo'd or printed string. ie "\r\n\t" should give you a new line and a tab before
outputting the content for a line of printing. They vary by OS, I know, but I have tried all the
variations I can think of and can't seem to control output using them. Believe me, I have tried
multiple variations and nothing works for me. I have checked the php.ini file for settings but I
can't find where you can modify them. So the question is : Where do i look to conf....
Converting Characters In A Variable To Individual Values In An Array
turning variables into arrays (2) Say I have a variable such as $nav_item and it had to contents Home . IE: CODE
$nav_item = 'Home'; How would I make so that $nav_item was an array and
had the following contents? CODE $nav_item = array ('h', 'o',
'm', 'e'); With the case changing (ie H would become h and U
would become u ) EDIT: Okay found out that I could change the case with
array_change_key_case ($nav_item, CASE_LOWER); ....
Max Characters Is X?
(3) I am currently making a code for my phpBB forum, where it will import the latest topics from a
specific forum, and display it on the news section of my main page. But the width of that news
section is very tiny, so I want the code to limit the numbers of characters to 25. So, let's
say this is the full title: "This is the title which is a little too long so it needs to be
shortened." This is what I want to show: "This is the title which ..." How can I do that?....
Counting Characters Of Textarea...
(3) good day webmasters... i am in need of a script that will count the inputted characters one will
enter... i mean the script must count the number of characters in a textarea as i am entering
characters to the textarea.. i know the logic but i cant translate it yet in PHP... so i hope you
can help me... thanks a lot in advance... /blink.gif' border='0' style='vertical-align:middle'
alt='blink.gif' /> ....
Converting Dates
converting epoch to MM-DD-YYY (1) So this is probably a basic and lame question, but how can I convert dates so I can then sort them?
Right now, I have each part of a date as a separate variable: $month, $day, $year.
I'd like to store them in the database as epoch. This way when I do a query I can sort them by
date. I can figure out the datatype for the database later. I would also need to convert an epoch
to Month-Day-Year later on when I want to display this. I'm sure this isn't too complicated
but I figured asking for some suggestions anyway. Thanks!....
Looking for converting, textarea, return, characters,
|
|
Searching Video's for converting, textarea, return, characters,
|
advertisement
|
|