Strip escaped html

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Strip escaped html

Post by amir »

I have the following code which I need to amend to strip out escaped html, which currently sits nested between "!!<<" and ">>!!" tags (no inverted commas!) . Can someone please advise how I can change the following code to do this and still have it output the correct number of characters and ensure it does not end with "&#" should "&#8226" overshoot the 95 characters:-

Code: Select all

<actinic:block php="true">

$sShort = "";
$sOriginal = "<actinic:variable encoding="html" name="ProductDescription" selectable="false" />";

if (strlen($sOriginal)>95)
{
$sShort = substr($sOriginal,0,95) . "...";
}
else
{
$sShort = $sOriginal;
}
$old = '&#149;';
$new = '&#8226;';
$exp = '/' . $old . '/';
$sShort = preg_replace($exp, $new, $sShort);
echo $sShort;
</actinic:block>
Cheers
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

So your looking for a regular expression replacement and string count?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm not entirely sure what you're looking for ~amir.
Post Reply