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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -