is there anyway for example when i navigate to http://example.com/links/pages/index.html
i have 4 .html files in /pages directory with names page1.html , page2.html , page3.html , page4.html
then that index.html must show me a list of pages that is exist in this /pages directory? without i list them on index.html manually by myself. i only want them to be listed at index.html when ever i create a new page at /pages directory
here's some example hope it helps : http://plnkr.co/edit/kIiod2DR6zgSpmuUNsUi?p=preview
or this example
<!-- This is index.html page in this directory http://example.com/links/pages/index.html -->
<html>
<head>
</head>
<body>
<!-- here must be listed pages that is exist in this directory /pages -->
<!-- example for to be listed -->
<ul>
<li><a href="page1.html">page 1</a></li>
<li><a href="page2.html">page 2</a></li>
<li><a href="page3.html">page 3</a></li>
<li><a href="page4.html">page 4</a></li>
</ul>
</body>
</html>
Here is an example:
in folder "pages" you have:
index.php in root directory will be:
<html>
<head>
</head>
<body>
<!-- here must be listed pages that is exist in this directory /pages -->
<?php
$dir = 'pages';
$pages = array_values(array_diff(scandir($dir), array('..', '.')));
?>
<ul>
<?php
foreach ($pages as $page) {
$name = str_replace('.html', '', $page);
echo "<li><a href=\"$page\">$name</a></li>";
}
?>
</ul>
</body>
</html>
the output will be:
<html>
<head>
</head>
<body>
<ul>
<li><a href="page1.html">page1</a></li>
<li><a href="page2.html">page2</a></li>
<li><a href="page3.html">page3</a></li>
</ul>
</body>
</html>