<?php
$code =
"image_n8938.jpg<br>
image_n3472.jpg<br>
image_n8342.jpg<br>";
$code = preg_replace("<<br>>","",$code);
$code = preg_replace('/^(.*)$/m', '<div class="image"><a href="/original/$1"><img src="/preview/$1"></a></div>', $code);
echo"$code";
?>