Home > Backend Development > PHP Tutorial > 正则去除图片width和height部分。该怎么解决

正则去除图片width和height部分。该怎么解决

WBOY
Release: 2016-06-13 13:45:21
Original
989 people have browsed it

正则去除图片width和height部分。
有许多图片,有的有width和height,有的没有width和height。

如何使用正则去除所有图片的width和height部分?我的代码无效,求助。

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<pre class="brush:php;toolbar:false"> 
<?php $s = '<img hspace="4" vspace="4" border="1" alt="Nagoya Institute folding X-Frame car lacks S-foils, hyperdrive, rolls on a big orange ball" src="http://www.blogcdn.com/www.engadget.com/media/2010/09/x-frame-2010-09-02-600.jpg" /> 
<img src="http://media02.hongkiat.com/speed-performance-check/pingdom.jpg" alt="Pingdom" border="0" title="18 Website Speed and Performance Checking Tools">
<img    style="max-width:90%" height="100px" src="http://blog.makezine.com/upload/2010/09/vice_grip_with_more_cowbell/expand-o.jpg" alt="expand-o.jpg">';
$img=preg_replace('/ width="\d+" height="\d+"/', '', $s);
echo $img;
?> 
Copy after login


------解决方案--------------------
PHP code
 <div class="clear">
                 
              
              
        
            </div>
Copy after login
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