我试图在保存到数据库时替换html iframe src上的高度和宽度。我查看了preg_replace函数和PCRE表达式,但无法解决这个问题。下面列出的是我的代码和样品输入php preg_replace换出iframe的高度和宽度
$pattern1 = '/width="[0-9]*"/';
$pattern2 = '/height="[0-9]*"/';
$subject = '<iframe src="http://player.vimeo.com/?title=0&byline=0&portrait=0" width="400" height="300" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
$returnValue = $preg_replace(array($pattern1, $pattern2), array('width="200"','height="200"'), $subject);
任何帮助将不胜感激!
干杯人!