在PHP中更改数组
我有以下代码:在PHP中更改数组,php,mysql,arrays,pdo,Php,Mysql,Arrays,Pdo,我有以下代码: $uid = $_SESSION['uid']; $sth = $db->prepare("SELECT groupid FROM user_groups WHERE userid=?"); $sth->execute(array($uid)); $sth->execute(); $results = $sth->fetchAll(PDO::FETCH_COLUMN, 0);// EIndimensionale Array print_r($resul
$uid = $_SESSION['uid'];
$sth = $db->prepare("SELECT groupid FROM user_groups WHERE userid=?");
$sth->execute(array($uid));
$sth->execute();
$results = $sth->fetchAll(PDO::FETCH_COLUMN, 0);// EIndimensionale Array
print_r($results);
这将为我带来以下输出:
数组([0]=>13[1]=>9)
但我需要这样的输出:
13,9
你能给我一个正确的提示吗。。。
非常感谢您只需使用
implode(",", $array);
打印前使用此选项。\r
$results = implode(",",$results);
祝你好运 执行查询两次!