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 Quote Link to comment 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']. '"'; } Quote Link to comment Share on other sites More sharing options...
rubahfgouveia Posted November 9, 2010 Author Share Posted November 9, 2010 worked as a charm. Thanks alot Quote Link to comment Share on other sites More sharing options...
mdewyer Posted November 9, 2010 Share Posted November 9, 2010 Sure thing! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.