Jump to content

php array


rubahfgouveia

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.