Log in

View Full Version : Random username and password from CSV file



young_coder
08-15-2010, 12:31 PM
Dear all,
Can somebody help me please?
Instead of ‘username’ and 'password', I need random values from CSV file.
Can somebody show me how can I do this?

My CSV file looks like this:

user001,userpass001
user002,userpass002
user003,userpass003

My script looks like this:

<?php
$t= new post();
$t->username='username';
$t->password='password';
$res = $t->update('This is some text.');
?>

Thank you very much advance.

djr33
08-15-2010, 03:32 PM
If you have many names (more than 100), it may run slowly. If you have thousands of names, it may run very slowly.

Here's some code to help:

$users = file('path/to/myfile.txt');
$user = array_rand($users);
$user = explode(',',$user,1);
$password = $user[1];
$username = $user[0];

young_coder
08-15-2010, 06:45 PM
Thank you djr33 :)