Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $directory = "work"; // Directory where the images are located:
- $myFiles = scandir($directory); // Grab a listing of you files:
- $allowedExts = ["jpg", "jpeg", "gif", "png"]; // Allowed image extensions:
- for ($i = 0; $i < count($myFiles); $i++) {
- /*
- * Obmit the . and .. in the directory
- */
- if ($myFiles[$i] !== '.' && $myFiles[$i] !== '..') {
- $ext = strtolower(pathinfo($myFiles[$i], PATHINFO_EXTENSION)); // Grab the extension of the file(s):
- if (in_array($ext, $allowedExts)) {
- $path_parts = pathinfo($myFiles[$i]);
- $file_name[] = $path_parts['filename'];
- }
- }
- }
- $num_files = count($file_name); // Number of images in lib/images/slideshow directory:
- echo "<pre>" . print_r($file_name, 1) . "</pre>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement