19 php
我有一个名为images/tips的目录.
现在在该目录中我有许多可以改变的图像.
我希望PHP脚本能够读取目录,查找图像以及找到随机图像的图像.
有关如何做到这一点的任何想法?
ale*_*lex 57
$imagesDir = 'images/tips/';
$images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
$randomImage = $images[array_rand($images)]; // See comments
Run Code Online (Sandbox Code Playgroud)
您可以发送第二个参数array_rand()以获得超过1.
| 归档时间: |
|
| 查看次数: |
48316 次 |
| 最近记录: |