On 11-02-15 04:03 PM, Brian Dunning wrote:
Hey all -
I've got long articles, the HTML for which comes out of MySQL. Works great. I want to split it up so that I can insert ad blocks at various points within it. The articles are all pretty long but they're of variable length. I want to chop them up into three close-to-equal (doesn't have to be) chunks of paragraphs, thus:
<p>Here's the original article</p>
<p>Here's the original article</p>
<p>Here's the original article</p>
<p>Here's the original article</p>
<p>Here's the original article</p>
Would become:
<p>Here's the original article</p>
<p>Here's the original article</p>
<?php include('first_ad'); ?>
<p>Here's the original article</p>
<p>Here's the original article</p>
<?php include('second_ad'); ?>
<p>Here's the original article</p>
Any suggestions? Thanks.
I came across the following recently which I used for a project:
http://simplehtmldom.sourceforge.net/
It allows accessing HTML tags via jquery like selectors. It may help you
to easily get at the spots you want. If your content is very uniform
then it may not be as efficient as a quick explode and traversal.
Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php