专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 帝国cms

帝国cms自动提取内容第一张图片为标题图片

发布时间: 文章来源:www.iduyao.cn 采编人员:毒药  
<?php
$sql=$empire->query("select * from {$dbtbpre}ecms_news order by onclick desc limit 1");
while($r=$empire->fetch($sql)){
$text=GetTxtFieldText($r[newstext]); //获取正文内容
$text1=substr($text,12);//去除exit
$datanr=stripslashes($text1); //册除反
$pattern ="/.*src=\\"([^^]*?)\\".*/i"; //正则取图片
preg_match_all($pattern,$datanr,$matchess);
$diypic=$matchess[1][0]; //取第一张图片地址
?>
<img src="<?=$diypic?>">
<?}?>
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
   2917阅读

内容页newstext调用多张图片+统计图片数量(张数)

<?php
$str = stripcslashes($navinfor[newstext]);
preg_match_all( '/<img.*?src="(.*?)".*?>/is', $str, $imgArr );
$imgArr = array_unique( $imgArr[1] );
?>
<?=count($imgArr)?>张
<img src="<?=$imgArr[0]?>">
<img src="<?=$imgArr[1]?>">
<img src="<?=$imgArr[2]?>">

毒药   2019-05-21 08:46:34
1

[e:loop={'news',10,18,1}]     
<?php
$fr=$empire->fetch1("select newstext from {$dbtbpre}ecms_news_data_{$bqr[stb]} where id='$bqr[id]'");
$str=stripcslashes($fr['newstext']);
preg_match_all('/<img.*?src="(.*?)".*?>/is',$str,$imgArr);
$imgArr = array_unique($imgArr[1]);
?> 
<?=count($imgArr)?>张                        
<img src="<?=$imgArr[0]?>"  width="200" height="200" />
<img src="<?=$imgArr[1]?>" width="200" height="200" />
<img src="<?=$imgArr[2]?>" width="200" height="200" />
<a href="<?=$bqsr['titleurl']?>"><?=$bqr['title']?></a><br>                  
[/e:loop]

毒药   2019-05-21 08:47:06
2
登录 后发表评论