Page 1 of 1

Extracting the first two paragraphs of a content

Posted: Mon Jun 29, 2009 9:46 am
by lauthiamkok
Hi,
I would like to extract the first two paragraphs of a content from a database, the code i got it from somewhere works fine only to extract one (first) paragraph in the content...

Code: Select all

<?php echo substr($row_feeds['pg_content'], 0, strpos($row_feeds['pg_content'], "</p>"));?>
how can i get around to this tricky part...?

Let's say this is my content from the database,

Code: Select all

<p>xxxxx</p>
<p>xxxxx</p>
<p>xxxxx</p>
Thanks,
Lau

Re: Extracting the first two paragraphs of a content

Posted: Mon Jun 29, 2009 1:24 pm
by Christopher
The first user contributed example on the strings page in the manual might work for you:

http://www.php.net/manual/en/ref.strings.php