Forum Moderators: coopster
I am trying to echo 2 results from a MySQL database and strip them to a maximum number characters and then words.
It works fine when I use it with one result but when I try to loop through two I get the following error:
Fatal error: Cannot redeclare ellistr() (previously declared in.
Here is my code:
$article = $row['text'];
if (strlen($article) > 30) {
$ext = ".. <a href='readmore.php'>read more</a>";
} else {
$ext = "";
}
function elliStr($s,$n) {
for ( $x = 0; $x < strlen($s); $x++ ) {
$o = ($n+$x >= strlen($s)? $s : ($s{$n+$x} == " "?
substr($s,0,$n+$x) . ".." : ""));
if ( $o!= "" ) { return $o; }
}
}
echo "<div class='headlinersub'>";
echo "<a href='search.php?t=$content_url'><h2>$title</h2> </a>";
echo (elliStr("$article", 50));
echo "</div>";
}[/code]
The error message says to me that it as previously been used or so on, I have tried numerous ways to correct it but failed - Could anyone lend me a hand here?
Cheers