Half way

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am tweaking a blog application I have programmed.  I am trying to
display a Google ad half through the blog entry, at the first available
<br />.

The code I use so far is:

$half_way = strlen( nl2br(stripslashes($entry))) /2 ;
$ad_position = strpos  ( nl2br(stripslashes($entry))  , "<br />" ,
$half_way );
echo substr( nl2br(stripslashes($entry)) , 0, $ad_position);

Is there a way to modify my strpos syntax to check and see if the
nearest <br /> is before the half way mark?  

What is tending to happen is the ad is being placed 5/7ths of the way
through the blog entry because of the length of the paragraph the half
way character falls in.  Visually it doesn't look balanced.  I would
prefer the ad display 4/7th of the way through the blog entry in those
situations.

Thanks for helping me.

Ron


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux