+ -
当前位置:首页 → 问答吧 → smarty 提取图片地址 在线等

smarty 提取图片地址 在线等

时间:2011-12-18

来源:互联网

array (
  'meta_Title' => '页面标题',
  'meta_Description' => '摘要',
  'meta_Keywords' => '',
  'intro' => '<p><img width="147" height="187" alt="" src="/uploadfile/1112/2011060818415046854.jpg" /><img alt="" src="/uploadfile/1112/2011060818415046854(1).jpg" /><img alt="" src="/uploadfile/1112/2011060818415046854(2).jpg" /><img width="0" height="0" alt="" src="/uploadfile/1112/2011060818415046854(3).jpg" /><img width="0" height="0" alt="" src="/uploadfile/1112/2011060818525452928.jpg" /></p>',
  'photo_narrate' => '',
  'photo' => '1/11_1324179006.jpg',
)



mysql数据库里面保存信息是上面的形式,如何在smarty里面把图片地址提取出来。。。

作者: aa513891516   发布时间: 2011-12-18

<?php


$arr = array (
  'meta_Title' => '页面标题',
  'meta_Description' => '摘要',
  'meta_Keywords' => '',
  'intro' => '<p><img width="147" height="187" alt="" src="/uploadfile/1112/2011060818415046854.jpg" /><img alt="" src="/uploadfile/1112/2011060818415046854(1).jpg" /><img alt="" src="/uploadfile/1112/2011060818415046854(2).jpg" /><img width="0" height="0" alt="" src="/uploadfile/1112/2011060818415046854(3).jpg" /><img width="0" height="0" alt="" src="/uploadfile/1112/2011060818525452928.jpg" /></p>',
  'photo_narrate' => '',
  'photo' => '1/11_1324179006.jpg',
);
 
preg_match_all("/src=\".+?\"/",$arr['intro'],$match);

$arr['imgSrc'] = $match[0];

作者: craboy1   发布时间: 2011-12-18