Ok I did what you told me, I read the file:
$fp = file('pwd.dat');
Now I have an array with al the lines in it.
To split one line with explode I did:
$data = $fp[15];
list($user,$pass,$exp,$path) = explode("::",$data);
Now the problem is that I just split line 15. Because I can only split one line.
Something else I looked at was the command preg_match:
if (preg_match ("/\bUSERNAME\b/", "$fp[15]")) {
print "Found match with login ".$user." and pass ".$pass;
} else {
print "Nothing found.";
}
Now if I would want to change the pass I use the implode:
$pass = "newpassword";
$array = array($user,$pass,$exp,$path);
$out = implode("::", $array);
No how can I write that line back to that certain line in the file? Do I first need to read the whole file? Any examples on the web?
Thank you