PHP - Add br tag after img tag

by Subramanian 2014-08-26 13:28:39

PHP - Add <br /> tag after <img> tag :

Example :

$string = '<img src="http://gvsubhu.com/subhu.jpg" /><img src="http://gvsubhu.com/subhu_1.jpg" />';
$result = preg_replace('/(<img[^>]+>(?:</img>)?)/i', '$1<br />', $string);

Output :
<img src="http://gvsubhu.com/subhu.jpg" /><br /><img src="http://gvsubhu.com/subhu_1.jpg" /><br />
1202
like
0
dislike
0
mail
flag

You must LOGIN to add comments