Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

680 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