$str = ''; $dom = new DOMDocument(); $dom->loadHTML($str); foreach($dom->getElementsByTagName('iframe') as $iframe) { $src = $iframe->getAttribute('src'); $src .= '?wmode=transparent'; // use a regex for better results $iframe->setAttribute('src', $src); } echo $dom->saveHTML(); '; $appendString = '/?wmode=transparent'; /* Youtube video sticky menu overlap fix */ $searchStartLen = strpos($videoEmbedCode, 'youtube'); $searchEndLen = strpos($videoEmbedCode, '"', $searchStartLen); $newVideoEmbedCode = substr_replace($videoEmbedCode, $appendString, $searchEndLen, 0); print $newVideoEmbedCode; ?> $doc = new DOMDocument(); $doc->loadHTML($your_html); foreach($doc->getElementsByTagName('iframe') as $iframe) { $iframe->setAttribute("src",$iframe->getAttribute('src').'?wmode=transparent'); } echo $doc->saveHTML();