Page 1 of 1

Strip escaped html

Posted: Wed Oct 18, 2006 2:28 pm
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

Posted: Wed Oct 18, 2006 2:34 pm
by RobertGonzalez
So your looking for a regular expression replacement and string count?

Posted: Wed Oct 18, 2006 2:36 pm
by feyd
I'm not entirely sure what you're looking for ~amir.