Php 随机显示多个图像
我能用吗Php 随机显示多个图像,php,Php,我能用吗 $im = imagecreatefrompng('1.png'); 并让它从一个文件夹中随机调用多个PNG图像 该网站是livlaughlov.com,现在它只使用一个PNG并在上面写文章,我希望它从文件夹中随机抓取一个PNG来写文章。您可以使用该功能并: 这个$folder='./dir/to/images/'$files=glob($folder.*.png')$兰德=兰德(0,计数($files)-1)$im=imagecreatefrompng($files[$rand])
$im = imagecreatefrompng('1.png');
并让它从一个文件夹中随机调用多个PNG图像
该网站是livlaughlov.com
,现在它只使用一个PNG并在上面写文章,我希望它从文件夹中随机抓取一个PNG来写文章。您可以使用该功能并:
这个<代码>$folder='./dir/to/images/'$files=glob($folder.*.png')$兰德=兰德(0,计数($files)-1)$im=imagecreatefrompng($files[$rand])$txt_background=imagecolorallocate($im、$bg_r、$bg_g、$bg_b)$txt_Color=imagecolorallocate($im、$txt_r、$txt_g、$txt_b)$阴影颜色=图像颜色分配($im、$shdw\U r、$shdw\U g、$shdw\U b);imagettftext($im、$txt_大小、$shdw_角度、$shdw_x、$shdw_y、$SHOW_颜色、$font、$string);imagettftext($im、$txt_大小、$txt_角度、$txt_x、$txt_y、$txt_颜色、$font、$string);标题('Content-Type:image/png');图像PNG($im);图像处理(港币);代码>
$folder = './dir/to/images/';
$files = glob($folder.'*.png');
$rand = rand(0, count($files)-1);
// random png image: $files[$rand];