Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

explode <p>somtihng</p> into array

Status
Not open for further replies.

letimati

Technical User
Feb 3, 2006
36
GB
Hi I have a variable for content of a website i have and i want to break up the text into paragraphys in an array.

So I have

$content = '<p>text 1</p><p>text 2</p><p>text 3</p>';

and i want this

$contentArray = array(1=>'<p>text 1</p>', 2=> '<p>text 2</p>', 3=><p>text 3</p>);

I guess the best way it to explode the text but not sure what to explode it around?

thanks in advance for any help
 
how about
Code:
$uid = uniqid("brk_");
$content = '<p>text 1</p><p>text 2</p><p>text 3</p>';
$content = str_replace("</p><p>", "</p>$uid<p>", $content);
$content_array = explode ($uid, $content);
 
Nice one that looks as it works great.

cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top