1
<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 , what I want and return a string equal to the title.
Model public Function listarProjetoPage($location, $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;
}
What do you want to achieve with this loop ?
– Edilson
I wish to return a shortened word as in the title...
– Marcus Daniel
Because this code is not known what is causing the error, basically it says, the work that php should do in up to 30 seconds took longer than that. Is it a consultation? post her.
– rray
The line 143 is
echo text_limiter_caracter($stred, 32, '...');
?– rray
Error solved .
– Marcus Daniel
To shorten a word/phrase you need a loop to ?
– Edilson