I am trying to separate a text HTML
containing iframes
from a preg_split
, and it does not come out. What I need is to create a array
with texts e iframes
. For example ['texto', 'iframe', 'iframe', 'texo']
.
What I have done has been this:
<?
php
$html = '<span style="font-size:14px;"><iframe allowfullscreen="" frameborder="0" height="360" mozallowfullscreen="" src="https://player.vimeo.com/video/34234234" webkitallowfullscreen="" width="640"></iframe></span></p>
<p>
<span style="font-size:14px;"><a href="https://vimeo.com/34234234"> Texto.</a> from <a href="https://vimeo.com/user7990284">Texto</a> on <a href="https://vimeo.com">Vimeo</a>.</span></p>
<p>';
$separacionIframes = preg_split('/(<iframe[^>]+>)/i', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
print_r($separacionIframes);
?>
What it paints me is a array
but like this:
['texto', 'iframe + texto']
and it should be ['texto', 'iframe', 'texto]
.
I do not know if I have explained myself well, any questions you may have ask me. Thank you very much!