//I use preg_replace_callback which calls a user defined function ever time it finds a match. In that function I check the $firstTime global variable. If its set it won't blank out the img. Afterward I search and remove any empty <a> tags.<?php$string = $item->get_content();$firstTime = true;$pattern = '/<img[^>]+?[>]/is';$string = preg_replace_callback($pattern, 'imgOff', $string);// remove empty <a> tags$pattern = '/<a[^>]*?[>]<\/a>/si';$replacement = '';$string = preg_replace($pattern, $replacement, $string);function imgOff($matches)// remove all but first img tag{ global $firstTime; if ($firstTime) { $firstTime = 0; return $matches[0]; // skip first img tag } return '';}?>