{php}
$temp=mt_rand(1,47);
$pattern='/<img[^>]*src="([^"]+)"[^>]*>/i';
$content = $article->Content;
preg_match_all($pattern,$content,$matchContent);
if(isset($matchContent[1][0]))
$temp=$matchContent[1][0];
else
$temp=$zbp->host."images/img/$temp.jpg";
{/php}

temp=mt_rand(1,47);的意思是随机显示图片名称1-47的图片。(图片需要按照1到47的名称命名)

images/img/$temp.jpg的意思是需要调用图片的路径(如果没有该路径创建即可,或者把images/img/改为你需要的),然后在需要显示的地方调用,直接填写{$temp}即可。

例如在文章开始的地方显示:<p><img src="{$temp}"></p>

需要注意的是,本代码显示的是图片的路径。

www.tstingmi.com 提供内容。