Read users and passwords from a txt file
PHP Snippet 1:
$lines = file('file.txt');
$credentials = array();
foreach($lines as $line) {
if(empty($line)) continue;
// whole line
$line = trim(str_replace(": ", ':', $line));
$lineArr = explode(' ', $line);
// username only
$username = explode(':', $lineArr[0]);
$username = array_pop($username);
// password
$password = explode(':', $lineArr[1]);
$password = array_pop($password);
// putting them together
$credentials[$username] = $password;
}
print_r($credentials);