I am working on a login service that accepts two fields ($username and $password) in login.html and passes them as post data to login.php. I am also to read a text document called 'pass.txt' into an array. The file looks like this.
anelhams0:7c4a8d09ca3762af61e59520943dc26494f8941b
jattenborough1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
nmalins2:7c222fb2927d828af22f592134e8932480637c0d
dlingley3:b1b3773a05c0ed0176787a4f1574ff0075f7521e
It continues for another 1800 or so lines. Each line of the txt file is a username:sha1password. I am to take the value for the username and check to see if it matches the username in the text file array. To do that I will need to instead separate the document by username and password only. so for example instead of array[0] being 'anelhams0:7c4a8d09ca3762af61e59520943dc26494f8941b' I need to separate it out to array[0] = 'anelhams0' and array[1] = '7c4a8d09ca3762af61e59520943dc26494f8941b' and array[2] = 'jattenborough1' and etc. I cannot find any way to do this because there are two separators I am using. Is there any way to accomplish this using some other function or a looping system? This is what I've got so far in login.php
<?php
//Takes our username and password
$username = $_POST["username"];
$password = $_POST["password"];
//read in our text file to an array (each element is a line from the text)
$fileSort = file('pass.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);