I read file (answers.txt
) and write values into an array
$filename = 'answers.txt';
$file = file($filename);
How I can add keys to the array? answers.txt
looks like:
212
150
200
212
I need to get keys like:
$array = array (
"first" => "212",
"second" => "150",
"third" => "200",
"four" => "212"
);
Hope you are looking for this
$keys=array("first","second","third","four");
$values=array(212,150,200,212);
$array_combine=array_combine($keys,$values);
print_r($array_combine);