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
Post a Comment