Cyberek Posted March 12, 2011 Share Posted March 12, 2011 Hello. Im working on a function: function image_vote_img_replace($content) { preg_match_all('/<img[^>]+>/i',$content, $result, PREG_PATTERN_ORDER); foreach ($result[0] as $img_oryg) { $result = '<div class="test">'.$img_oryg.'</div>'; $content = preg_replace( $img_oryg, $result , $content ); } return $content; } It gets as input content from CMS. It supposed to add overlaping div to each <img src="xxxx" /> so it looks like: <div class="test"><img src="xxxx" /></div>. But instead i get: <<div class="test"><img src="xxxx" /></div>> with additional < and > at beginning and end. I thin ,that it might be first regexp problem, but in second hand - entire img is extracted properly... Thanks in advice. Martin. Link to comment https://forums.phpfreaks.com/topic/230461-preg_replace-problem/ Share on other sites More sharing options...
Cyberek Posted March 12, 2011 Author Share Posted March 12, 2011 Found solution $content = preg_replace("#$img_oryg#s", $result , $content ); Link to comment https://forums.phpfreaks.com/topic/230461-preg_replace-problem/#findComment-1186773 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.