-1

i have this code:

$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);

This bring me this output: Array ( [0] => 13 [1] => 9 )

But I need a output like this: 13, 9

Can you pleas give me the right hint... Thanks a lot

Ingo
  • 27
  • 1

2 Answers2

2

You can simply use

implode(",", $array);
Asgu
  • 712
  • 5
  • 15
2

Use this before print_r

$results = implode(",",$results);

Good luck!

Duenna
  • 2,186
  • 2
  • 14
  • 17