1

我有一个来自数据库的数组,我只想留下productnames没有要显示的数组结构。

public function selectAll () 
{
    $stmt = Database::get()->query('SELECT `productname` FROM retrofootball_products');
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

这个的输出是

Array ( [0] => Array ( [productname] => Manchester City 1981 Centenary FA Cup Final Shirt ) [1] => Array ( [productname] => Manchester City 1999 Playoff Winning Shirt ) )

我想留下来

Manchester City 1981 Centenary FA Cup Final Shirt, Manchester City 1999 Playoff Winning Shirt
4

2 回答 2

4

如果你想用逗号分隔使用implode

于 2013-01-07T06:00:04.287 回答
1

您可以使用implode

implode(',', $smt->fetchAll(PDO::FECTH_ASSOC));
于 2013-01-07T06:00:26.033 回答