Php 获取数据库中的表并以字符串形式存储

Php 获取数据库中的表并以字符串形式存储,php,mysql,Php,Mysql,我正在使用此代码向连接到的数据库显示表列表,但我无法将它们放入字符串中。 我希望从数据库中获取表列表,并将它们存储在字符串中 $result = mysql_query("show tables"); // run the query and assign the result to $result while($table = mysql_fetch_array($result)) { // go through each row that was returned in $result

我正在使用此代码向连接到的数据库显示表列表,但我无法将它们放入字符串中。 我希望从数据库中获取表列表,并将它们存储在字符串中

$result = mysql_query("show tables"); // run the query and assign the result to $result

while($table = mysql_fetch_array($result)) { // go through each row that was returned in $result
    if ($table) {
        $aw = array();
        $count= 0;                              
        $aw[$count] = $table[0];
        echo $string = array($aw[$count]);

        $count++;
    }
}

为什么要使用echo$string=array($aw[$count])

我认为这也应该解决这个问题:

echo$string=$aw[$count]


正如您所评论的,您希望将其设置为CSV格式,例如,如果您希望将其直接放置到文件中,您可以查看一下。否则,这里有一个生成CSV字符串的函数。

谢谢,但我也想将数据转换成CSV格式。我不太明白生成CSV字符串的函数是如何工作的。您能帮助我吗