Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 随机显示多个图像_Php - Fatal编程技术网

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];