Display latest image in directory ending in

后端 未结 2 354
情深已故
情深已故 2021-01-28 12:11

I\'d like to display the last modified image in a directory that ends in a specific way.

I have it working to display the last file in the directory I only don\'t know h

2条回答
  •  梦毁少年i
    2021-01-28 12:48

    This should sort it out for you, basically just add another rule to filter in images ending in your required field.

    Basically just use the strpos() function to determine if the value you are looking for is in the file name.

    Also wrapped the code within a function, allowing bot the desired folder location, and desired string which the file must end in.

     $newest_mtime) {
                        $newest_mtime = $mtime;
                        $show_file = "$base_url/$latestFile";
                    }
                }
            }
        }
        return $show_file;
    }
    
    echo 'Latest from the web';
    ?>
    

提交回复
热议问题