There are two errors in your code.
The first mistake is simple, you are copying infinitely all content from $arr
to $row
, one solution would be to use foreach
.
foreach($arr as $row) {
echo $row['nome'];
}
Let's go to the second error, note that you are using fetch
in line $resultado = $result->fetch(PDO::FETCH_ASSOC);
which will return only one line at a time, so result will have an associative array with the first line, I recommend using fetchAll
so this line would look like this:
$resultado = $result->fetchAll(PDO::FETCH_ASSOC);