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

hibernate - How to load global settings frequently used in application in Java -

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

objective c - Ownership modifiers with manual reference counting -