-
-
Save illuzor/c4b938c4af3f47416c1b6b890d1337d8 to your computer and use it in GitHub Desktop.
This file contains 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 | |
$folders = array_diff(scandir("images_previews", 1) , array('.',"..")); | |
$result = []; | |
foreach($folders as $k => $v) { | |
$result[$k] = ["name" => $v, "preview" => random_file("images_previews/" . $v)]; | |
} | |
function random_file($dir) { | |
$files = glob($dir . '/*.*'); | |
$index = array_rand($files); | |
return $files[$index]; | |
} | |
echo json_encode($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment