Solved

Need HTML Paragraph Tag added to beginning of Each Line Entered into a Form.

Posted on 2007-03-22
3
189 Views
Last Modified: 2007-03-22
Hi,

Thanks for Your help.

I need the code to be able to add a <p> tag at the beginning of each line when I enter text into a form.

Example:

I paste the following into a form:

Curabitur eget ligula. Vivamus iaculis euismod felis. In magna. Quisque eu sapien. Suspendisse
accumsan. Curabitur eros felis, adipiscing quis, suscipit in, congue eget, enim. Nulla consectetuer
ante condimentum velit. Etiam commodo magna ac nulla. Sed ornare. Sed vulputate lacinia urna.
Etiam nec dui.

Output is:
<p>Curabitur eget ligula. Vivamus iaculis euismod felis. In magna. Quisque eu sapien. Suspendisse
<p>accumsan. Curabitur eros felis, adipiscing quis, suscipit in, congue eget, enim. Nulla consectetuer
<p>ante condimentum velit. Etiam commodo magna ac nulla. Sed ornare. Sed vulputate lacinia urna.
<p>Etiam nec dui.

Thank You VERY VERY Much for Your Help!

:)

FirstBorn
0
Comment
Question by:FirstBorn
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
exoska earned 500 total points
ID: 18775802
try this, where text is your var.

$text = preg_replace('/^(.)/sim', '<p>\\1', $text);
0
 
LVL 1

Author Comment

by:FirstBorn
ID: 18776190
Hi Exoska,

Thank You VERY VERY VERY Much!!!

That Did the Trick!

:)

FirstBorn
0
 
LVL 3

Expert Comment

by:exoska
ID: 18776199
oh i m glad :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Popup to change image and store url in database 2 30
Amazon Redshift 2 26
MySQL Grouping 2 23
Selecting SUM data from mysql table with PHP 4 6
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now