Jump to content

PHP array issue please help :-)


karenkane

Recommended Posts

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

<?php

          include 'FTPLogins.php';

         

          $userOutputString = "";

 

            foreach($USERS as $v)

            {

                $userOutputString .= "<option>" . $v['username'] .  "</option>";

            }

          echo $userOutputString;

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.