rubahfgouveia Posted November 9, 2010 Share Posted November 9, 2010 Hey all, I have the following code: <? $result = mysql_query("SELECT A,B FROM USS"); $num_rows = mysql_numrows($result); for($i = 0; $i < $num_rows; $i++) { $nome_utilizador = mysql_fetch_row($result); $user = $nome_utilizador[0] . " ". $nome_utilizador[1]; $teste[] = $user; } ?> Currently me array is filled in the following way : $array[] -> [aaa,bbb,ccc]; but what I need is it to fill up with the "" wrapped around each entry : $array[] -> ["aaa","bbb","ccc"]; . I know json_encode does something like what I need, but I'm not sure how to echo each element of a json_encode.. I would really appreciate the help. Thanks alot, Ruben Link to comment https://forums.phpfreaks.com/topic/218167-php-array/ Share on other sites More sharing options...
mdewyer Posted November 9, 2010 Share Posted November 9, 2010 If I follow you correctly, here's how I would do it: $result = mysql_query("SELECT A,B FROM USS"); while ($row = mysql_fetch_assoc($result)) { $teste[] = '"' .$row['A']. ' ' .$row['B']. '"'; } Link to comment https://forums.phpfreaks.com/topic/218167-php-array/#findComment-1132101 Share on other sites More sharing options...
rubahfgouveia Posted November 9, 2010 Author Share Posted November 9, 2010 worked as a charm. Thanks alot Link to comment https://forums.phpfreaks.com/topic/218167-php-array/#findComment-1132322 Share on other sites More sharing options...
mdewyer Posted November 9, 2010 Share Posted November 9, 2010 Sure thing! Link to comment https://forums.phpfreaks.com/topic/218167-php-array/#findComment-1132336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.