By default preg_replace
will replace all the matches it encounters. You can limit the number by adding a parameter.
preg_replace( '/regex/', 'replaceWith', $string, $noOfMatches );
Hope that answers your question, Good luck.
If you're looking for the regex itself then a quick match to that string would be..
'#<p><img class\="mceItem" src\="http:\/\/img\.youtube\.com\/vi\/PZVfZ9TmW6w\/0\.jpg" alt\="PZVfZ9TmW6w" width\="306" height\="229" \/><\/p>#'
I just escaped the special characters. Here is a cheatsheet on regex. If you're parsing HTML a lot, you might want to check into something called DOMDocument in PHP. It lets you manipulate the dom structure and makes the process simple when you learn how to use it.
If you're just starting out I recommend SimpleHTMLDom parser, which comes in a single file to drag onto your server. It's simpler and a good introduction. There are a lot of examples as well. It's maintained here.
Edit: Okay, to get the video id first with regex..
preg_match_all( '#img\.youtube\.com\/vi\/(.*?)\/#', $searchString, $matches );
foreach( $matches[1] as $vid_id )
{
$iframe_string = '<iframe width="560" height="345" src="http://www.youtube.com/embed/'.$vid_id.'" frameborder="0" allowfullscreen></iframe>';
preg_replace( '#<p><img class\="mceItem" src\="http:\/\/img\.youtube\.com\/vi\/\'.$vid_id.\'\/0\.jpg" alt\="'.$vid_id.'" width\="306" height\="229" \/><\/p>#', $iframe_string, $searchString );
}