Hi
I have this script that is part of an already working RSS, now what I want to do is
to add a string replace, which shortens strings that are too long and adss ... instead.
this is the original code:
function show_user_html()
{
$show = (sizeof($this->rss) > $this->num_to_show + $this->offset ? $this->num_to_show : sizeof($this->rss));
$show = ($this->offset + $this->num_to_show > sizeof($this->rss) ? sizeof($this->rss) - $this->offset : $this->num_to_show);
for($i = $this->offset; $i < $this->offset + $show; ++$i) {
extract($this->rss[$i]);
$item = preg_replace("/#\{([^}]+)}/e", "$\\1", $this->my_html);
echo $item;
}
}
here Is my modification, but it doesn't work. what am I doing wrong?
function show_user_html()
{
$show = (sizeof($this->rss) > $this->num_to_show + $this->offset ? $this->num_to_show : sizeof($this->rss));
$show = ($this->offset + $this->num_to_show > sizeof($this->rss) ? sizeof($this->rss) - $this->offset : $this->num_to_show);
for($i = $this->offset; $i < $this->offset + $show; ++$i) {
extract($this->rss[$i]);
$item2 = preg_replace("/#\{([^}]+)}/e", "$\\1", $this->my_html);
$MAX_LENGTH = 22;
$str_to_count = html_entity_decode($item2);
$item = substr($str_to_count, 0, $MAX_LENGTH - 3);
$item .= "...";
return htmlentities($item);
echo $item;
}
}