0

i have this code:

<p> paragraph </p>
<p> another paragraph 
<iframe frameborder="0" src="https://www.youtube.com/embed/GXIAE">
</iframe></p>

How can i take the iframe out from the paragraph into like this :

 <p> paragraph </p>
 <p> another paragraph </p>
 <iframe frameborder="0" src="https://www.youtube.com/embed/GXIAE"></iframe>

I have tried by using regex below but doesn't work

   $string = preg_replace('<p[^>]*>[^<]*\K(<iframe[^>]*><\/iframe>)(.*?<\/p>)','$2$1', $string);

1 Answers1

0

Give your <iframe> and your <p> an id, then refer to them via their ids. You can then do whatever you want with them, like "moving" one of them.

Tobias F.
  • 1,050
  • 1
  • 11
  • 23
  • i was working facebook instant article for my website, but the iframe not showing because the iframe inside the paragraph tag. – Meimei Kiss' Jul 26 '17 at 14:30