I want to remove from server-side (php) the iframe tag of an embedded Google Map.
It's a symfony 1.4 project and I want to remove this from the action before serving the html to the response.
The tag looks something like this. At first glance it seems a task to be solved using regex.
<p>
<iframe width="425" height="350" src="http://maps.google.com/maps/ms?hl=en&mpa=0&ctz=-60&mpf=0&ie=UTF8&msa=0&t=m&vpsrc=6&msid=207463975658802969656.0004b1369c88b98702faa&ll=44.705998,8.068085&spn=0.085403,0.145912&z=12&iwloc=0004b136a142301cefe0c&output=embed"></iframe>
<br><small>View <a href="http://maps.google.com/maps/ms?hl=en&mpa=0&ctz=-60&mpf=0&ie=UTF8&msa=0&t=m&vpsrc=6&msid=207463975658802969656.0004b1369c88b98702faa&ll=44.705998,8.068085&spn=0.085403,0.145912&z=12&iwloc=0004b136a142301cefe0c&source=embed">Test</a>
in a larger map</small>
</p>
Is there any other solution or a valid regex which could do this?
I would like only the <iframe>
tag to be removed if possible
You could use preg_replace():
echo preg_replace("#<p>(.*)<iframe(.*?)maps.google.com(.*?)</iframe>(.*)</p>#is", '', $string);