-1

I'd like to search for this start of iframe tag in text (articles from a database)

<iframe 

and replace it to this:

<div class="embed-responsive embed-responsive-16by9"><iframe 

I've tried str_replace (but this one works from left to right) and preg_replace kills the entire code.

to be more precise, this is what needs to be done:

$article = str_replace("<iframe scr", "<div class="embed-responsive embed-responsive-16by9"><iframe class=\"embed-responsive-item\" scr", $article);
KJS
  • 1,176
  • 1
  • 13
  • 29

1 Answers1

0

Watch your single and double quotes:

$article = str_replace('<iframe scr', '<div class="embed-responsive embed-responsive-16by9"><iframe class=\"embed-responsive-item\" scr', $article);
FoulFoot
  • 655
  • 5
  • 9