This will echo out all files in the directory called myfiles that are called test1.php, test2.php, but not hello.php
1 2 3 4 5 6 7 |
<?php foreach (glob("myfiles/test*.php") as $dog) { echo $dog; } ?> |
To alphabetically sort files
1 2 3 4 5 6 7 8 9 |
<?php $files = glob("myfolder/test*.php"); sort($files); foreach ($files as $file) { echo $file.'<br />'; } ?> |