Función que busca una URL en un texto y la pone como enlace en HTML muy útil para comentarios.
function findReplaceURL($text){
// The Regular Expression filter
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
// Check if there is a url in the text
if(preg_match($reg_exUrl, $text, $url)) {
// make the urls hyper links
return preg_replace($reg_exUrl, "<a href=".$url[0].">".$url[0]."</a> ", $text);
} else {
// if no urls in the text just return the text
return $text;
}
}0
Puntos
Puntos
2733
Visitas
Visitas
2
Resp
Resp
Por zerodarck hace 11 años
Master
Respuesta #1
Como aplico esto? ya lo puse en funciones y no me va
Cap:
<img src="http://fotos.subefotos.com/52ec37761795541e28e0317d5a8ab96ao.png"/>
Cap:
<img src="http://fotos.subefotos.com/52ec37761795541e28e0317d5a8ab96ao.png"/>
0
Puntos
Puntos
Por maxial29 hace 11 años
Novice
Respuesta #2
bueno. Sería así
maxial29 dijo:Bueno, tomando como ejemplo tu imagen maxial29. Tienes tu consulta que saca los comentarios, bueno supongamos que la variable de fetch_array es.. $getComment
Como aplico esto? ya lo puse en funciones y no me va
Cap:
<img src="http://fotos.subefotos.com/52ec37761795541e28e0317d5a8ab96ao.png"/>
bueno. Sería así
<?php echo findReplaceURL($getComment[" "]); ?>
0
Puntos
Puntos
Por jose hace 11 años
Master