我有以下 PHP 代码:
while($row = mysqli_fetch_array($query))
{
$data = $row['name'];
}
我在数据库中获取列名为 "name" 的所有数据。怎么才能这样输出呢?
["John", "Doe", "Deer"]
最佳答案
您必须将 $data 设为数组类型变量。
while($row = mysqli_fetch_array($query))
{
$data[] = $row['name'];
}
print_r($data); // required output
关于php - 使用 PHP 输出数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35868186/