473,467 Members | 1,303 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

str_replace doesn't find "\n\n"

I'm trying to "html-ise" some text, where an empty line should be
interpreted as a paragraph break.

I thought that
$text = str_replace("\n\n", "</p><p>", $text);
would work, but that doesn't find anything to replace in my strings, and
$text = str_replace("\n", "</p><p>", $text);
gives me too many paragraphs, of course.

As an example of what I want, this message should be divided into three
paragraphs.
Jul 17 '05 #1
1 4736
Martin Magnusson wrote:
I'm trying to "html-ise" some text, where an empty line should be
interpreted as a paragraph break.

I thought that
$text = str_replace("\n\n", "</p><p>", $text);
would work, but that doesn't find anything to replace in my strings,
and $text = str_replace("\n", "</p><p>", $text);
gives me too many paragraphs, of course.

As an example of what I want, this message should be divided into
three paragraphs.


It's possible your text contains a carriage return as well as line
break. In that case, you'd want to do this:

$text = str_replace("\r\n\r\n", "</p><p>", $text);

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Jul 17 '05 #2

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

Similar topics

0
by: L Mehl | last post by:
Hello -- A textbox, txtSubsRate, on a form has its DataFormat property set to Percentage. The result is that a user entering a decimal value of ".nn" sees "nn%" in the text box. In an...
2
by: Simon Wigzell | last post by:
I'm on a different computer running win 95 with IE 5 my website on a new dedicated server and I'm getting "Done, but with errors on page" appearing in the browser status area which I have never...
1
by: TPG | last post by:
I'd like a Javascript function I have written to be invoked whenever *any* new document is been loaded into a particular frame (i.e I don't control the incoming document's BODY tag). Under...
2
by: Olaf | last post by:
I have a frameset page witch contains the myFuc() function. The function is accessed from a page in one of the frames in the frameset. An example is shown below. <input...
2
by: Ori :) | last post by:
I am writing an application to retrieve appointments from Outlook, I have the appointment items sorted by "Start" field and now I want to find the first record which's "Start" value is later than...
38
by: axlq | last post by:
I'm trying to figure out how to display a box that has a width in "em" units. So far no luck. Below is some HTML that displays two rows of 30 'm' characters in lowercase and uppercase, followed...
8
by: Ryan | last post by:
Hello, I'm new to Access and DB's in general. I've taken over some light duty support for a lab information system we use in house. Most of our dates are reported as "10/31/2006 12:30:00 PM"...
2
by: Steven W. Orr | last post by:
>From the tutorial, they said that the following construct will automatically close a previously open file descriptor: ------------------- #! /usr/bin/python import sys for nn in range ( 1,...
4
RMWChaos
by: RMWChaos | last post by:
Darnit all, I expect the code I steal from others to work! =D Below is some code that I got to initiate multiple javascripts on page load (rather than using the "onload=" attribute). According the...
26
by: Jake Barnes | last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching for "how to play a sound with Javascript". I'm somewhat suprised that the majority of entries are from the 1990s, and there are...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.