Solved

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

Posted on 2007-03-22
3
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

617 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