Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove iframe tag from a string?

Tags:

php

I have this type of string, with an iframe (youtube video). How can I remove iframe from the string end echo only text?

Scelerisque scelerisque. Sit elit vut sit, aliquam. Elementum. Enim dignissim nisi mauris, aliquet aenean, proin, porttitor tristique et, pulvinar tincidunt! Diam risus eu diam, ultrices diam pulvinar platea ridiculus augue adipiscing aliquet adipiscing a mid lundium, ultricies eros, pulvinar? Etiam, sagittis dignissim egestas sit.<iframe width="560" height="315" src="http://www.youtube.com/embed/f8Q_BHzJ0fI" frameborder="0" allowfullscreen></iframe>Cum integer. Sit nisi. Augue, risus, scelerisque aliquam aliquet nunc nascetur purus! Diam ut sit lundium a phasellus ac pulvinar egestas nec! Lectus urna habitasse lacus turpis nunc quis tortor integer.
like image 918
Sasha Avatar asked Feb 21 '13 16:02

Sasha


1 Answers

$string = preg_replace('/<iframe.*?\/iframe>/i','', $originalString);
like image 176
Andrei Filonov Avatar answered Oct 03 '22 15:10

Andrei Filonov