I have the following sitemap:
[url]http://www.otc.edu/sitemap/sitemap.php
I’m reading in a text file from this page. I have a few things in PHP which I’m not sure how it would be done.
1.
Is there a way using a regex that I could check for directories and only display the top level URL for each directory? For example, the “about” directory has many pages inside, when all I need to display is the home page, index.php. I have more pages being crawled and sent to Google that I don’t want showing up.
Is there a sort command that would organize the listing of each directory? Right now, it’s not in the correct order.
Would there be a way to display the directory and then the filename, such on this page?
[url]http://www.otc.edu/sitemap/sitemap.html
Thanks for any suggestions you can provide. Script is below:
[code=php]<?php
$theFile=fopen(“urllist.txt”, “r”);
//error check to ensure we can open the text file and get results back, if not, display a //warning.
if(!$theFile){
echo “Couldn’t open the data file. Try again later.”;
}
else{
//read the contents of the text file
while(!feof($theFile))
{
$data=explode(“n”, fgets($theFile));
print “<tr>n”;
for($i=0;$i<=count($theFile);$i++){
print “<td>$data[$i]</td>”;
}
print “</tr>n”;
}
//done with the file, call the fclose function, passing variable
fclose($theFile);
}
?>