我試圖在保存到數據庫時替換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);
任何幫助將不勝感激!
乾杯人!