I am trying to import 2 separate text files into an array then echo the result. One file contains street names, the other contains street descriptions:
for example:
Street Name - Its a nice street.
So far I am able to import the 1st file into an array and see the result using a foreach loop.
When I try to nest another foreach loop within the first one i get nothing. Trying to figure out what i am doing wrong.
My apologies, i am really new to PHP.
<?php
$lines = file('files/streetnames.txt');
$lines2 = file('files/streetDescriptions.txt');
foreach ($lines as $streetName => $line) {
echo htmlspecialchars($line);
foreach($lines as $streetDes => $line2){
echo htmlspecialchars($line2);
break;
}
}
?>
The data in the 1 text file(streetNames.txt):
Anderson Mill Road
The data in the second file is (streetDescriptions.txt) is
Named after a mill and its owner, Thomas Anderson, who lived in the vicinity in the 1850s.
The result I am trying to achieve is:
Anderson Mill Road - Named after a mill and its owner, Thomas Anderson, who lived in the vicinity in the 1850s.