Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   [php] Links verkürzen (https://www.delphipraxis.net/83633-%5Bphp%5D-links-verkuerzen.html)

Angel4585 5. Jan 2007 12:25

Re: [php] Links verkürzen
 
Also deins hab ich nicht hinbekommen, aber mit dem #ie hab ich rumprobiert und so meins hinbekommen, das sieht jetzt so aus:

Code:
function makeurl($prot,$url){
if(strlen($url)>15)
  $show = substr($url,0,6).'...'.substr($url,-6,6);
else $show = $url;
return "<a href=\"".$prot.$url."\" target=\"_blank\">".$show."</a>";
};

function hrefs($string){
  // URLs verlinken:
  $string = ' ' . $string;
  $string = preg_replace("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#ie", "makeurl(\"\",\"\\2\")", $string);
  $string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#ie", "makeurl(\"http://\",\"\\2\")", $string);

  return $string;

};
Danke :thumb:

PS: es sind zwei für einmal mit protokoll und einmal nur www :zwinker:


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:00 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz