Jump to content
php.lv forumi

Linku konvertieris


smarty

Recommended Posts

nu kaa, ja es uzrakstu

function find_res($text) {

  $patt='/(http(s?):\/\/|ftp:\/\/)([^\/]*)([^ ]*)/i';

  return preg_replace_callback($patt, 'wrapurl', htmlspecialchars($text));

}

 

function wrapurl($matches) {

  return '<a href="'.$matches[1].$matches[3].$matches[4].'">'.$matches[3].'</a>';

}

 

bet peec tam tekstu wrapoju

$txt    = find_res($txt);

$txt    = ereg_replace("([^ ]{60})","\\1<br />", $txt);

tad tas urlis shaa vai taa tiek sabojaats

Link to comment
Share on other sites

jaa viss jau buutu labi, ja man nevajadzeetu wrapot textu!!

respektiivi, ja teksts ir

tad rezultaats ir

sdfs sgd fgdfg <a class="clink" href="http://www.google.lv/search?hl=lv&q=baigi+labais+skrip<br />ts&btnG=Google+mekl%C4%93%C5%A1ana&meta=" target="_blank">http://www.google.lv/search?hl=lv&q=baig&hel<br />lip;</a>

sdfsdfsf s gsdg

 

(pa vidu ir atstarpe linkaa)

Edited by smarty
Link to comment
Share on other sites

×
×
  • Create New...