You can use foreach here just fine.
foreach ($rows as $row) {
echo $row['id'];
echo $row['firstname'];
echo $row['lastname'];
}
I think you are used to accessing the data with numerical indicies (such as $row[0]
), but this is not necessary. We can use associative arrays to get the data we're after.