<?php
function limitarPalabras($cadena, $longitud, $elipsis = "...")
{
$palabras = explode(' ', $cadena);
if (count($palabras) > $longitud)
return implode(' ', array_slice($palabras, 0, $longitud)) . $elipsis;
else
return $cadena;
}
$consulta2 = "select tid,fid,pid,subject,username FROM mybb_posts order by pid desc";
$sql2 = mysql_query($consulta2) or die (mysql_error());
$c = 0;
$lasids[0] = "";
while($row = mysql_fetch_array($sql2) AND $c <= 5) {
$ok = false;
foreach($lasids as $numero => $valor ) {
if ($valor == $row['tid']) { $ok = true; }
}
if($ok == false) {
$lasids[$c] = $row['tid'];
$post = str_replace("Re: ", "", $row['subject']);
$post = str_replace("RE: ", "", $post);
$post = str_replace("¿", "¿", $post);
$post = str_replace("¿", "¿", $post);
$post = str_replace("á","á",$post);
$post = str_replace("Á","Á",$post);
$post = str_replace("é","é",$post);
$post = str_replace("É","É",$post);
$post = str_replace("í","í",$post);
$post = str_replace("Í","Í",$post);
$post = str_replace("ó","ó",$post);
$post = str_replace("Ó","Ó",$post);
$post = str_replace("ú","ú",$post);
$post = str_replace("Ú","Ú",$post);
$post = str_replace("ñ","ñ",$post);
$post = str_replace("Ñ","Ñ",$post);
$elalt = $post;
echo "<li style='list-style:none; padding-bottom: 4px;'>- <a style=\"color:#fff; \" alt=\"".$elalt."\" title=\"".$elalt."\" href=\"../foros/showthread.php?tid=".$row['tid']."\">".limitarPalabras($post,8)."</a></li>";
$c++;
}
}