Estoy intentando separar un texto HTML
que contiene iframes
a partir de un preg_split
, y no me sale. Lo que necesito es crear un array
con textos e iframes
. Por ejemplo ['texto', 'iframe', 'iframe', 'texo']
.
Lo que he hecho ha sido esto:
<?
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);
?>
Lo que me pinta es un array
pero de esta forma:
['texto', 'iframe + texto']
y tendría que ser ['texto', 'iframe', 'texto]
.
No sé si me he explicado bien, cualquier duda que tengáis preguntádmela. Muchas gracias!!
/(<iframe[^>]*>.*?</iframe>)/is
en tal caso