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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -