I'm using the following function to create a leadin to articles.
function snip($text, $maxTextLength)
{
global $abstract;
$aspace=" ";
//$abstract = strip_tags($text);
$abstract = ereg_replace('<([^>]|\n)*>', '', $text);
$abstract = substr(trim($text),0,$maxTextLength);
$abstract = substr($abstract,0,strlen($abstract)-strpos(strrev($abstract),$aspace));
$abstract = $abstract .'...';
}
It works, in as far as it creates $abstract which is a snippit of $text, cut off at $maxTextLength (a number of characters).
However, the striptags function didn't work, so I tried the ereg_replace funtion, and that doesn't work either.... I'm still getting <br /> and other tags in the resulting $abtract.
The snip function is in an included file, along with other functions which all work as expected.
If I move the striptags function to within the same page, it does seem to work - but I really need it where it is.
Any ideas? Thanks.