Created
March 22, 2018 14:27
-
-
Save akmandev/7f5cbc0514621030f51ce7d901dc654f to your computer and use it in GitHub Desktop.
Fastest way to get random files from a directory (Recursively)
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 | |
$directory = '/folder/name/etc'; | |
$length = 100; | |
$command = 'find "' . $directory . '" -type f | shuf -n ' . $length . ';'; | |
exec($command, $paths); | |
// $paths will contain every files with their paths as an array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment