I have a simple query :
$Consulta = $pdo->query(" SELECT * FROM dados ")->fetchAll();
foreach ($Consulta as $key)
{
echo $key["InfoDado"];
}
If you run foreach
out of a function! beauty! It works as it should!
But I tried to execute this foreach
inside a function and it gave error!
Can you execute this foreach
within a function? Something like:
function ExecutarForeach()
{
foreach ($Consulta as $key) {
echo $key["InfoDado"];
}
};
ExecutarForeach();