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. Quote Link to comment 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 ); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.