karenkane Posted September 15, 2009 Share Posted September 15, 2009 I have two PHP files, 1 contains a list of usernames and passwords and is called FTPLogins.php Example of FTPLogins.php <?php $USERS[0]["username"] = "admin"; $USERS[0]["password"] = "admin"; $USERS[1]["username"] = "guest"; $USERS[1]["password"] = "guest"; $USERS[2]["username"] = "test"; $USERS[2]["password"] = "test"; ?> in the other I am trying to make a list of the users in FTPLogins.php in a list form and here is a code snippet <select name="usrLIST" size="10" > <?php include 'FTPLogins.php'; $usrTotal = count($USERS[0][0]); $userOutputString = ""; for ($i = 0; $i < $usrTotal; $i = $i + 1) { $userOutputString .= "<option>" . $USERS[$i]["username"] . "</option>"; } echo $userOutputString; ?> </select> Can anyone tell me how to make this work? Link to comment https://forums.phpfreaks.com/topic/174370-php-array-issue-please-help/ Share on other sites More sharing options...
Garethp Posted September 15, 2009 Share Posted September 15, 2009 <?php include 'FTPLogins.php'; $userOutputString = ""; foreach($USERS as $v) { $userOutputString .= "<option>" . $v['username'] . "</option>"; } echo $userOutputString; ?> Link to comment https://forums.phpfreaks.com/topic/174370-php-array-issue-please-help/#findComment-919158 Share on other sites More sharing options...
karenkane Posted September 15, 2009 Author Share Posted September 15, 2009 That works so elegantly! Thank you so much!!! Link to comment https://forums.phpfreaks.com/topic/174370-php-array-issue-please-help/#findComment-919165 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.