1
I have a query simple:
$Consulta = $pdo->query(" SELECT * FROM dados ")->fetchAll();
foreach ($Consulta as $key)
{
echo $key["InfoDado"];
}
If you execute the foreach
of it out of a function! beauty! Works as it should!
But I tried to execute that foreach
inside a function and gave error!
You can run this foreach
within a function? Something like:
function ExecutarForeach()
{
foreach ($Consulta as $key) {
echo $key["InfoDado"];
}
};
ExecutarForeach();
You will have to pass the variable
$Consulta
for the function.function ExecutarForeach($Consulta) {...}
– stderr
@stderr It worked brother! Thank you!
– ivan veloso