I am trying to read from a txt file and then exlplode the contents of each line to remove the delimiter to form a 2d array so I may reference individual entries by $Data[$num][$num] e.g.
Third one |first_radio|email@yahoo.com
exploded to get each entry individually. I am using the folowing code:
$lines = file($file_name); // form array of lines
foreach($lines as $Key => $Val) {
$Data[$Key][] = explode("|", $Val);
echo "Line ".$Key." :".$Val."<br>"; // just to check lines are correct
}
echo "<br>Test Line Entry before implementing a loop:<br>";
echo "Answer(s) 1: " . $Data[0][0]."<br>";
echo "Answer 2: " . $Data[0][1]."<br>";
echo "Answer 3: " . $Data[0][2]."<br>";
I keep getting the output 'Answer(s) 1: Array'.
Can anyone please suggest my error in attempting this approach?