Reply to reading in multiarray

Your name:

Reply:


Posted by Jon Slaughter on 04/19/07 22:11

I wrote some code to read in a file

and I'm curious as to is this is a decent way to do it or if there is a much
more elegant way. Essentially I want to convert a text file that into a ul
in html for my nav menu. This way I can easily add and remove links without
messing with any other code(Except of course where the link points to).

Anyways, the code works as far as getting the links into a multi-array that
I can work with but not sure if its the best way or not.

--------Links.txt--------
Home
About
Mathematics
-Tutorials
-Works
-Other
-Misc
Computers
-Tutorials
-Misc


<?php
echo 'Opening Links.txt...<br>';

$lines = file('./Links.txt');

// Get links into array
$s = 0;
$k = -1;
foreach ($lines as $line_num => $line)
{

if ($line[0] != '-')
{
$s = 0;
$k++;
$Links[$k][$s] = $line;
} else
{
$s++;
$Links[$k][$s] = $line;

}

}

// print links.
foreach ($Links as $link)
{
foreach ($link as $llink)
{
echo "$llink<br>";
}
}


?>

Thanks, Jon

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация