Created
May 17, 2017 22:03
-
-
Save NandoKstroNet/14e314692a68b379d26c2a24393f92d3 to your computer and use it in GitHub Desktop.
List files in a specific directory, in a pattern based.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$link = ''; | |
$pattern = "*.pdf"; | |
function mountLink(string $file, string $link, string $ext = '.pdf') :string | |
{ | |
return "<a href=\"{$link}{$file}\" target=\"_blank\">" . str_replace($ext, '', $file) . "</a>\n"; | |
} | |
foreach (glob($pattern) as $file) { | |
echo mountLink($file, $link); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment