y porque no haces una funcion fuera del while que procese el texto y te retorne la respuesta, aqui una muestra con un array:
Código PHP:
Ver original 'Este es el Enlace 1 http://muestradeenlace1.com',
'Este es el Enlace 2 http://muestradeenlace2.com',
'Este es el Enlace 3 http://muestradeenlace3.com',
'Este es el Enlace 4 http://muestradeenlace4.com',
);
function enlace($X){
$text = $X;
$text = preg_replace("#http://[a-z0-9._/-]+#i", "<a href='$0'>$0</a>", $text); $regex = "#[ ]+(www.([a-z0-9._-]+))#i";
$text = preg_replace($regex," <a href='http://$1'>$1</a>", $text);
return $text;
}
foreach ($texto as $key => $value) {
echo "<li>".enlace($value)."</li>";
}
a mi me funciono perfecto así, tambien lo probe con una consulta a mysql y realizó el trabajo tambien.