2
I’m putting values in a array
and I need to display these values on the side of the titles in th
of a table
.
I don’t want to use a loop to traverse the array, I want to access the value through the Indice.
It follows my function that feeds the array
and sends to the view
public function index() {
$novas = $this->model->countSituacaoNova();
$analise = $this->model->countSituacaoAnalise();
$aprovada = $this->model->countSituacaoAprovada();
$reprovada = $this->model->countSituacaoReprovada();
$pendente = $this->model->countSituacaoPendente();
$paga = $this->model->countSituacaoPaga();
$data = array(
'novas' => $novas,
'analise' => $analise,
'aprovada' => $aprovada,
'reprovada' => $reprovada,
'pendente' => $pendente,
'paga' => $paga
);
$situacoes['situacao'] = $data;
//var_dump($data);
$this->load->view('propostas_view', $situacoes);
}
Follows a passage from view
with the table
where I try to use the value of array
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Em análise (<?php echo $situacao['novas']; ?>)</th>
<th>Aprovadas</th>
<th>Reprovadas</th>
<th>Pendentes</th>
<th>Pagas</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
mine array
$novas
has it:
array (size=1)
0 =>
object(stdClass)[22]
public 'Novas' => string '1' (length=1)
Error:
Message: Array to string conversion
What mistake does the ?
– Henrique Felix
Message: Array to string conversion
– HawkB
Give a dd() in your array and see its contents
– Henrique Felix
The variable
$novas
is getting an even integer amount? Check if an array is not coming.– Renato Diniz
truth.. is coming an array in
$novas
– HawkB