PHP正则匹配查看原图,该怎么解决

WBOY
Release: 2016-06-13 11:45:51
Original
1041 people have browsed it

PHP正则匹配查看原图
哪位高手帮忙写个正则匹配内容:
$str='内容内容内
容内容内容内容内容内容PHP正则匹配查看原图,该怎么解决内容内容内容PHP正则匹配查看原图,该怎么解决';
匹配效果:
$str='内容内容内
容内容内容内容内容内容PHP正则匹配查看原图,该怎么解决原图内容内容内容PHP正则匹配查看原图,该怎么解决原图';
------解决方案--------------------

$str = '内容内容内<br />容内容内容内容内容内容<img  src="http:www.wz.com/1.jpg"   style="max-width:90%" height="100px;" / alt="PHP正则匹配查看原图,该怎么解决" >内容内容内容<img  src="http:www.wz.com/2.jpg"/ alt="PHP正则匹配查看原图,该怎么解决" >';<br /><br />echo preg_replace('/<img .*?src="([^"]+).*? alt="PHP正则匹配查看原图,该怎么解决" >/is', '$0<a href="$1">原图</a>', $str); 
Copy after login
内容内容内
容内容内容内容内容内容PHP正则匹配查看原图,该怎么解决原图内容内容内容PHP正则匹配查看原图,该怎么解决原图

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!