get_random_file
get_random_file($folder,$extension,$flag_inc_subfolders); - this function is used to get a random file path in the specified folder
The function accepts parameters as input:
$folder – path to the folder where the file will be searched (string). It can be either absolute or relative (relative to the script folder).
$extension – file extension, among which you can choose$flag_inc_subfolders – whether to include subfolders in the search area (true - include, false - do not include) .
After testing, the function returns the result of its work to the script :
file path – the path to a randomly selected file in the specified folder (string)false – there is no such folder (boolean)