Answer the question
In order to leave comments, you need to log in
How to copy links to all .html files in a folder?
Welcome all.
There is a folder with .html files :
Is it possible to copy links to all .html files in the folder using php (or in another way)?
What it is for:
To then take these links and paste them on another page, so that a person would go to this page and see how many .html files there are in the project and could follow them.
For if this is not done, the portfolio will simply have a link to the .index file, and there are different projects, there are some 20 files, and I want to first transfer the person to links.php and that there would be a list of all .html files and he already clicked I myself on all these links and not just admired only 1 index.html page, and that I would not manually copy all this from all projects, but make it semi-automatic or automatic mode for current and future projects.
Please tell me how this can be approximately implemented, can anyone have ideas or experience?
Answer the question
In order to leave comments, you need to log in
ATP Alex for the tip on the scandir()
function We managed to
implement our plans =)
<?php
#файл links.php в корневой папке
$dir = './';
$files = scandir($dir);
function filter_html($link) {
if (stripos($link, '.html')) {
return true;
}
}
$html_links = array_filter($files, 'filter_html');
echo '<ul>';
foreach ($html_links as $elem) {
echo "<li><a href=\"$elem\" target=\"_blank\">$elem</a></li>";
}
echo '</ul>';
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question