Solved

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

Posted on 2007-03-22
3
188 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

746 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

13 Experts available now in Live!

Get 1:1 Help Now