0

This is my HTML code:

<img src="http://img.youtube.com/vi/ErIRt52MOkE/0.jpg" class="mceItem" alt="ErIRt52MOkE"/>

And I want transform this code like this:

<iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/ErIRt52MOkE" frameborder="0" allowfullscreen></iframe>

This my pattern: (Message: preg_replace() [function.preg-replace]: Unknown modifier 'v')

<img(?=[^>]+?class="mceItem")(?=[^>]+?alt="[\w]+?")[^>]+?img.youtube.com/vi/([\w]+?)/0.jpg[^>]*?/>
2
  • Yes, that's possible. There are other questions like this. Use the search function to find other tips. Then update your question with attempts you made, so it gets a little less broad or a plain coding inquiry. Commented Apr 28, 2012 at 21:53
  • 1
    Well, escape your delimiters. Or use e.g. # instead of /. Commented Apr 29, 2012 at 0:10

1 Answer 1

0

Try this:-

<?php
  preg_match_all('%youtube\.com\/vi\/([^\/]+)%','<img src="http://img.youtube.com/vi/ErIRt52MOkE/0.jpg" class="mceItem" alt="ErIRt52MOkE"/>',$matches);

  print_r($matches);

  $outputStr = '<iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/'.$matches[1][0].'" frameborder="0" allowfullscreen></iframe>';

  echo $outputStr;
?>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.