I have a file read.txt
with records like this
pulp_fiction
Pulp Fiction
jurassic_park
Jurassic Park
inception
Inception
I want to read these content of the file to an associative array like this in quest.php
<?php
$quest ["pulp_fiction"] = "Pulp Fiction";
$quest ["jurassic_park"] = "Jurassic Park";
$quest ["inception"] = "Inception";
this is the code that opens the file for writing in the quest.php I need help in the array part. thks
<?php
$myFile = "read.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
$assoc_array = array();
$my_array = explode("
", $theData);
foreach($my_array as $line)
{
$tmp = explode("
", $line);
$assoc_array[$tmp[0]] = $tmp[1];
}
fclose($fh);
// well the op wants the results to be in $quest
$quest = $assoc_array;
?>
I have this section of code saved as quest.php and am calling in quiz.php but when I try to match the image title with the actual title, nothing populates.