Php replace iframe by amp-iframe


Php replace iframe by amp-iframe It is very simple and easy to replace normal iframe to amp-iframe in Php. here in this article we are going to explain how to convert iframe tag to amp iframe.


Php replace iframe by amp-iframe Example

You can replace iframe tag by amp-iframe tag simply using the below code-

Php replace iframe by amp-iframe Example:

<?php
$content = "Hello world <iframe src='xyz.com/abc.htm'></iframe> ";
$resultTemp = str_replace('<iframe', '<amp-iframe', $content);
echo $resultFinal = str_replace('</iframe>', '</amp-iframe>', $resultTemp);
?>

The above code will convert all occurrence of iframe to google amp iframe tag.


Advertisements

Add Comment