I have an inc file (menu.inc) that has Urls and Titles in it seperated with a space like so:
Yahoo http://www.yahoo.com
MSN http://www.msn.com
ESPN http://www.espn.com
I am trying to store them in an array, so I can iterate over them multiple times on a page without having to open the file multiple times.
START OF CODE
$links = file("../../../webinc/menu.inc");
$linksArray = array();
foreach ($links as $link) {
$i = explode(" ",$link);
array_push($linksArray, $i);
}
foreach ($linksArray as $onelink) {
echo "<a href=\"" . $onelink[1] . "\">" . $onelink[0] . "</a> ";
}
?>
FIXED PROBLEMS
I can open the file and read the contents, but I only return the first and second characters of each line. I am apparently missing the seperator (" ") in this case, but don't know where to put it.