php - change my output format -
my php code :
$q = $db->query("select username users limit 3"); $users = array(); while($row = $db->fetchall($q)) { $users[] = $row; } foreach($users $user) { echo $user['username'].'<br>'; }
and output be
nilsen michael sam
does possible change output format nilsen,michael,sam
without start foreach ?
any idea please ?
thank you.
while($row = $db->fetchall($q)) // fetchall wired here, since result, asume that's right { $users[] = $row['username']; }
then use:
echo join(',' $users);
Comments
Post a Comment