ExpressYourself
Registered
Как мога да проверя в даден string дали има линк? и вместо линка да добавя ЛИНК и href към него 
Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?
$str="http://abv.bg";
$preg=preg_match('/^www|http:\/\//', $str);
if ($preg)
{
if (!preg_match('/^http:\/\//', $str))
{
$add="http://";
}
else
{
$add="";
}
$rep=str_replace("$str", '<a href="'.$add.''.$str.'" target="_blank">ЛИНК</a>', $str);
echo $rep;
}
else
{
echo $str;
}
?>
kulov каза:така ли имаш в предвид :
Код:<? $str="http://abv.bg"; $preg=preg_match('/^www|http:\/\//', $str); if ($preg) { if (!preg_match('/^http:\/\//', $str)) { $add="http://"; } else { $add=""; } $rep=str_replace("$str", '<a href="'.$add.''.$str.'" target="_blank">ЛИНК</a>', $str); echo $rep; } else { echo $str; } ?>
<?php
$text = "tuka ima http://abv.bg tuka nema http://web-tourist.net/forum , a puk tuka ima mnogo dulug http://site.com/b?g=X98uJHIy87%20l";
$text = preg_replace("/(http:\/\/[^\s]+)/i","<a href=\"$1\">$1</a>",$text);
echo $text;
?>
<?php
$str="http://abv.bg";
if (preg_match('/^www|http:\/\//', $str))
{
if (!preg_match('/^http:\/\//', $str)) $add="http://";
$str=str_replace($str, '<a href="'.$add.$str.'" target="_blank">ЛИНК</a>', $str);
}
echo $str;
?>
защото просто не са нужни. Условията са пък още по ненужни. За цялото това нещо можеше да използваш preg_replace.$add.''.$str