![]() |
Text File Into Array
I have text file which goes like
username1|pass1 username2|pass2 I want to split it so all of the usernames are in one array and all the passwords are in one array. How can I do this? Thanks, Nathan |
I have the solution.
I will post in half an hour since I need to go. |
php Code:
|
You could also make the loop so it puts an index number for each user.
PHP Code:
|
Quote:
$i, it'll still help with making member listing or members count functions. :-!It's overkill. |
Yea, but it could be a nice way to assign userid's ;)
Ofcourse it's optional :) |
May I answer now? Here's my solution:
php Code:
You will then have an array of user names in $aUsername, and their respective passwords in $aPassword.$szText will be your string:Quote:
|
Use file to load the usernames and passwords in the text file into an array. Everyone is skipping that step.
|
Quote:
|
I just want to point out that it can be a very bad idea to use
file. Depending on the size of the file contents you could be better off parsing the file in chunks using a temporary buffer, this is especially true when dealing with large files. |
Just to offer up another approach (simply to show there are always other options available) here's one using the lovely function: fgetcsv
PHP Code:
|
| All times are GMT. The time now is 01:01 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0