1
For example. I am working with Heredoc and whenever I need to do a for, I have to close Heredoc to do the for then open the mentioned tag again.
Is there any way to query a variable within the is that will return all results to me? For example.:
$telefones = 3;
for($i = 0; $i < $telefones; $i++) {
$numero_tel = $buscar_telefones[$i]['numero'];
$todosNumeros = "telefone: $numero_tel";
}
echo <<< EOT
$todosNumeros
EOT;
PRINT : telephone: 9999-9999 telephone: 9999-7777 telephone: 9999-8888
Thank you very much !
This returning me error
Parse error: syntax error, unexpected T_VAR
– Diego Henrique
Sorry, I used a syntax of PHP4. See now.
– Leonel Sanches da Silva
I tried this way but he returned only one number. Did not return the three. Thanks for the help.
– Diego Henrique
@Diegohenrique I made several corrections. See if now meets you.
– Leonel Sanches da Silva
@Gypsy Morrison Mendez is not required to create the variable before, outside the for. A variable created inside the for can be perfectly accessed from outside it.
– LeoFelipe
It’s just that I went more by the title of the question, but you’re right.
– Leonel Sanches da Silva