473,388 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How to detect a line break in a multiline textfield

Hi can someone give me the code to convert a line break in a multiline
textfield to a <br/tag ? It's something to do with CR LF but I can't
find the exact code anywhere.
Cheers,
Ciarán

Feb 28 '07 #1
3 19245
Ciaran wrote:
Hi can someone give me the code to convert a line break in a multiline
textfield to a <br/tag ? It's something to do with CR LF but I can't
find the exact code anywhere.
Cheers,
Ciarán
nl2br
Feb 28 '07 #2
Hendri Kurniawan wrote:
Ciaran wrote:
>Hi can someone give me the code to convert a line break in a multiline
textfield to a <br/tag ? It's something to do with CR LF but I can't
find the exact code anywhere.
Cheers,
Ciarán
nl2br
Sorry, Need to clarify this.
nl2br converts line break to HTML br tag.
If you want to change from <br/tag to CRLF, do a str_replace instead.
I've no recollection any functions that will convert br tag to CRLF
(as far as i know anyway)

Hendri Kurniawan
Feb 28 '07 #3
Thanks for the reply Hendri. I got it sorted out using a simple find
and replace I found by searching for nl2br thanks to your second
post.

Converting textarea line breaks to <brin PHP
$result = str_replace(array("\r\n", "\r", "\n"), "<br />",
$thestring);

Converting <brto textarea line breaks in PHP:
$result= str_replace(array("<br/>", "<br>", "<br />"), "\n",
$thestring);

Hope this helps someone,
Ciarán

Feb 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roland Dalmulder | last post by:
Hello all, In my PHP script I put a text file into a string. Part of that string is read, changed and removed. The while loop continuest to extract the next part of the string. This goes all...
5
by: Wai Yip Tung | last post by:
When I do for line in fp: the line string usually has a '\n' at the end. In many cases I don't want the line break character. I can trim it using if line.endswith('\n'): line = line ...
1
by: Rocketman | last post by:
I am trying to find out when i reach the next line when multiline is switched on and i DON'T PRESS ENTER TO GO TO THE NEXT LINE(lines method is there for that purpose). Is there any other method i...
6
by: Nurchi BECHED | last post by:
Hello, All! I have created an application with a multiline textbox on the form. When I press a button, it has to show something and then break the line and show something else. I tried "\n",...
9
by: jsummit | last post by:
I'm trying to parse a rather large string from a .txt file that breaks into 2 lines ( the string is a fixed-length string reaching 6694 characters) into a dataset using VB.net. The issues that I am...
3
by: lmawler | last post by:
Hi all, I know when I do data entry, I can force a line break in a text box by using Control & Enter. I'm trying to insert a line break in a field (that behaves like Control Enter) from VB. ...
4
by: deerchao | last post by:
Hi, I'd like to render colorful text with word wrap on screen (kind of inline <fonttag to change text color in html), but run into the line break problem. Graphics provides several DrawString...
1
by: mccalla | last post by:
Hi all, Tricky question. I know how to remove line break characters and spaces by using the code below: $message =~ s/\n//g; $message =~ s/\s//g;
7
by: jeddiki | last post by:
Hi, I am using a function called htmlwrap() which states that it does NOT add a "<br>" to the 70 character line so that it forces a line wrap. ( the script safely wraps long words without...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.