请问帝国CMS内容页正文插入随机序号的图片
- 准备命名规则的图片,例如
1a.jpg
,2a.jpg
等。 - 使用 PHP 的
rand()
函数随机插入图片。 - 图片路径固定,名称使用随机数。
- 示例代码:
<div class="rand"> <?php $string = $navinfor['newstext']; $some = "<img "; $num = explode($some, $string); if (count($num) > 1) { echo $navinfor['newstext']; } else { echo $navinfor['newstext']; ?> <script> document.getElementsByClassName('rand')[0].children[2].innerHTML += '<p><img src="/images/<?=rand(1, 100)?>a.jpg" alt="<?=$bqr['title']?>"></p>'; </script> <?php } ?> <p>[!--page.url--]</p> </div>
更新时间:2025-04-11 00:41:04
下一篇:请问帝国cms和织梦哪个好
转载请注明原文链接:https://www.muzicopy.com/suibi/6238.html