I have the following array:
array(2) {
[0]=>
array(2) {
["username"]=>
string(6) "User01"
["quant"]=>
string(1) "6"
}
[1]=>
array(2) {
["username"]=>
string(5) "Teste"
["quant"]=>
string(1) "3"
}
[2]=>
array(2) {
["username"]=>
string(5) "xxXxx"
["quant"]=>
string(1) "5"
}
}
How do I get all the "username" fields and list, "User01, Test, xxXxx"
I found a function that lists only the array id:
$resultado[0][username];
echo $resultado;
User01
I just printed the value set la [0], but I want it to print all the username.
Here is the complete code, but only the last regit.
$sql = 'SELECT username, COUNT(*) AS quant FROM acessos WHERE hora > :hora GROUP BY username';
$statement = $pdo->prepare($sql);
$statement->bindValue(":hora", date('H:i:s', strtotime('-1 minutes')));
$statement->execute();
$resultado = $statement->fetchAll(PDO::FETCH_ASSOC);
//var_dump($resultado);
foreach($resultado as $item){
$dados = $item["username"];
}
echo "-> " . $dados;
-> xxXxx