For example, I have a file .user1-info
and the content of the file is:
nick="Test"
password="403926033d001b5279df37cbbe5287b7c7c267fa"
join_date="1111111111"
rank="1"
How do I make an array with the content to use it as a database? For example:
echo $usr_info['nick']
I did not doubt what your relationship is with the database.
To transform the data from a file as this format (I think that is one format .ini), you can use the native php function parse_ini_file.
// Parse without sections
$ini_array = parse_ini_file(".user1-info");
print_r($ini_array);
/*
Array
(
[nick] => "Test"
[password] => "403926033d001b5279df37cbbe5287b7c7c267fa"
[pasjoin_dateword] => "1111111111"
[rank] => "1"
)
*/
Use explode to split each line by the equal sign.
$array = explode("=", $line, 1); // splits only by first equal sign
The first array element will be your key and the second will be very close to your value.
You can parse it as a ini
file, because your format is very much like that, use parse_ini_file() for that, like this:
$usr_info = parse_ini_file($file_path);