<tr>
<td id="titulo">
<a href="./visualizar" data-html="true"
data-trigger="hover" data-container="body" data-toggle="popover" data-placement="right" data-content="<?= $p[$i]->titulo; ?>">
<?php
$str = $p[$i]->titulo;
echo text_limiter_caracter($str, 32, '...');
?>
</a>
</td>
<td id="edital">
<span data-html="true" data-trigger="hover" data-container="body" data-toggle="popover" data-placement="right" data-content="<?= $p[$i]->edital; ?>" >
<?php
$stred = $p[$i]->edital;
echo text_limiter_caracter($stred, 32, '...');
?>
</span>
</td>
</tr>
function text_limiter_caracter($str, $limit, $suffix = '...')
{
while (substr($str, $limit, 1) != ' ') {
$limit--;
}
if (strlen($str) <= $limit) {
return $str;
}
return substr($str, 0, $limit + 1) . $suffix;
}
The system is returning me an unwanted loop, which I want and return a string equal to the title.
Model publicfunctionlistProjectPage($situation,$start,$max){
$sql="SELECT t1.titulo,t3.nome as edital, t2.nome as area
FROM projeto t1
INNER JOIN areaconhecimento t2 on (t2.id = t1.idAreaConhecimento)
INNER JOIN edital t3 on (t3.id = t1. ) WHERE t1.situacao = $situacao ORDER BY t1.titulo LIMIT $inicio, $max";
$stmt = $this->conn->prepare($sql);
$stmt->execute();
return $stmt->fetchAll();
}
Controller
function listarProjetoPage($situacao, $inicio, $max) {
$resultado = $this->projetos->listarProjetoPage($situacao, $inicio, $max);
return $resultado;
}