3raser Posted March 27, 2012 Share Posted March 27, 2012 The below script WILL list one account successfully, but how come this script doesn't list more than one account when <b>listAccounts()</b> is called? EXAMPLE OF accounts.txt FILE: username:blah user526:pass justinlh:justin function listAccounts() { //load all the accounts $accounts = loadAccounts(); //display each account in the drop-down box foreach($accounts as $account) { $account_split = explode(':', $account); echo '<option value="'. $account .'">'.$account_split[0].'</option>'; } } function loadAccounts() { /* EXAMPLE OF ACCOUNTS.TXT * http://pastebin.com/zAPH0a4J */ $handle = fopen('accounts.txt', 'r'); $accounts = fread($handle, filesize('accounts.txt')); fclose($handle); return explode('\n', $accounts); } Quote Link to comment Share on other sites More sharing options...
Jessica Posted March 27, 2012 Share Posted March 27, 2012 After $accounts = loadAccounts(); add this line: print_r($accounts); What do you get? Quote Link to comment Share on other sites More sharing options...
3raser Posted March 27, 2012 Author Share Posted March 27, 2012 Thanks! That helped me fix the problem. Everything was being smashed into Array [0] =>. The \n was suppose to be in double quotation marks. ;P Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.