How to create a login system with Twey's unique file function.
Well, all the credits from this piece of snippet goes to Twey(it's his function with some minor changes).
Code:
<?php
function newfile($filename, $sep){
$lines = file($filename);
$config = array();
for($i = 0; $i < count($lines); ++$i)
$config[substr($lines[$i], 0, strpos($lines[$i], $sep))] = substr($lines[$i], strpos($lines[$i], $sep) + 1, -1); // -2 for a Windows host
return $config;
}
print_r(newfile('newfile.txt'));
?>
Code:
test1|test2
test3|test4
test5|test6
This is an extremely useful function in PHP file handling(it makes things a heck lot easier). Hope you find it useful. Kudos to Twey.