G
G
GoodProject2021-07-30 09:51:25
PHP
GoodProject, 2021-07-30 09:51:25

How to copy links to all .html files in a folder?

Welcome all.
There is a folder with .html files :

jCbp12h.png
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

2 answer(s)
G
GoodProject, 2021-07-31
@GoodProject

ATP Alex for the tip on the scandir()
function We managed to implement our plans =)
C8qK7wI.png

<?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>';
?>

A
Alex, 2021-07-30
@Kozack

I think
https://www.php.net/manual/ru/function.scandir.php will help you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question