每篇内容根据段落判断插入图片代码附上:
- $chatd="
";- if(stripos($content,$chatd)==0){
- //随机输出三张图功能
- if($moduleid!=37 &&$thumb==''){
- //判断是否存在图
- $id=rand(1,999999);
- $mid=rand(1,9999999);
- $getimg="http://www.nongpin88.com/randimage/".$moduleid."/".$itemid.".png";
- $getimgs="http://www.nongpin88.com/randimage/".$moduleid."/".$id.".png";
- $getimgss="http://www.nongpin88.com/randimage/".$moduleid."/".$mid.".png";
- $count = substr_count($content,'');//获取p标签的数量
- $j = 0;//</p>重新定位用的
- //判断多少个p
- if($count<9){
- $num = 0;//这里是在1/3的位置插入,可以修改为rand(1,$count);这样就是随机位置插入了
- if($count<6){
- $numone=null;
- $numtwo=null;
- }else{
- $numone=($count-1);
- $numtwo=null;
- }
- }
- elseif($count>8 && $count<12){
- $num = 1;
- $numone=6;
- $numtwo=9;
- }else{
- $num = 1;
- $numone=floor($count/2);
- $numtwo=($count-1);
- }
- for($i = 0; $i < $count; $i++){
- $j = strpos($content, '', $j);
-
- if($i == $num){
- $content = substr($content, 0, $j) . ('
'" />
') . substr($content, $j); - }elseif($i==$numone){
- $content = substr($content, 0, $j) . ('
'" />
') . substr($content, $j); - }elseif($i==$numtwo){
- $content = substr($content, 0, $j) . ('
'" />
') . substr($content, $j); - }
-
- $j = ($j+1);
- }
- }
-
- }
这样就ok了,根据段落自动插入图片

演示地址:校园欺凌的观后感_醉学网
-
相关阅读:
HMS Core基于地理位置请求广告,流量变现快人一步
数据库——模式分解和关系范式的分解
众所周知,配置即代码≠基础设置即代码
SpringClouldAlibaba 之 初识 Nacos
Java设计模式之策略模式
geteway我的一些记录
echarts 配置方法使用记录
女子垒球市队建设实施办法·野球1号位
Word处理控件Aspose.Words功能演示:使用 Python 保护 Word 文档
YOLOv7独家原创改进:最新原创WIoU_NMS改进点,改进有效可以直接当做自己的原创改进点来写,提升网络模型性能精度
-
原文地址:https://blog.csdn.net/luo2424348224/article/details/133325117