arrays - How to assign PHP variables from foreach loop output? -


i have foreach loop prints out usernames of entries in database table so:

foreach($results $result){  echo $result->username; echo '<br>';  } 

as more , more users added table, list grow. take complete list , assign each entry separate php variable use later on php script. best way this?

you don't want individual variables, try array:

foreach($results $result){     $names[] = $result->username; } 

Comments

Popular posts from this blog

python 3.x - Mapping specific letters onto a list of words -

javascript - jquery or ashx not working -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -