[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

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

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
FirstBorn
Asked:
FirstBorn
  • 2
1 Solution
 
exoskaCommented:
try this, where text is your var.

$text = preg_replace('/^(.)/sim', '<p>\\1', $text);
0
 
FirstBornAuthor Commented:
Hi Exoska,

Thank You VERY VERY VERY Much!!!

That Did the Trick!

:)

FirstBorn
0
 
exoskaCommented:
oh i m glad :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now