Chinaunix首页 | 论坛 | 博客
  • 博客访问: 288426
  • 博文数量: 93
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 830
  • 用 户 组: 普通用户
  • 注册时间: 2016-02-25 10:44
个人简介

一杯茶,一台电脑

文章分类

全部博文(93)

文章存档

2018年(4)

2017年(57)

2016年(32)

分类: PHP

2017-01-22 14:01:22


  1. function GetOneImgUrl($img,$ftype=1){
  2.     if($img <> ''){
  3.         $dtp = new DedeTagParse();
  4.         $dtp->LoadSource($img);
  5.         if(is_array($dtp->CTags)){
  6.         foreach($dtp->CTags as $ctag){
  7.             if($ctag->GetName()=='img'){
  8.                 $width = $ctag->GetAtt('width');
  9.                 $height = $ctag->GetAtt('height');
  10.                 $imgurl = trim($ctag->GetInnerText());
  11.                 $img = '';
  12.                 
  13.                 if($imgurl != ''){
  14.                     if($ftype==1){
  15.                         $img .= $imgurl;
  16.                     }
  17.                     else{
  18.                         $img .= '.$imgurl.'" width="'.$width.'" height="'.$height.'" />';
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.     }
  24.         $dtp->Clear();
  25.         return $img;
  26.     }
  27. }

阅读(867) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~