Solved

<p> Encapsulation </p>

Posted on 2006-11-06
3
258 Views
Last Modified: 2012-08-13
Hullo there.
I was wondering if anyone would know how to make a function that takes a string (provided in the parameters) and treats every \n as the end and start of a <p> element (excluding the first occurrence). In other words:

$string = "I am about to be\nprocessed."

would become:

$string = "<p>I am about to be</p><p>processed.</p>"

Thanks for your help, experts
0
Comment
Question by:blizzdek
  • 2
3 Comments
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 50 total points
Comment Utility
blizzdek,

I would first try using replace.  You may need to strip the opening paragraph tag from the end of the string though and add a starting paragraph tag.

$string = str_replace("\n","</p><p>", $fullstring);

Let me know if you have any questions or need more information.

b0lsc0tt
0
 

Author Comment

by:blizzdek
Comment Utility
I can't believe I forgot that str_replace existed. Thanks :D
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
Your welcome!  I'm glad that I could help.  Thank you for the grade, the points and the fun question.

bol
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
This article discusses four methods for overlaying images in a container on a web page
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.

762 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

9 Experts available now in Live!

Get 1:1 Help Now