url-afkorten-na-x-aantal-karakters
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?
//--- check url's on length ---//
function checkurl($url)
{
//--- url must begin with http:// or intern links will occur ---//
if (substr($url, 0, 7) != "http://")
$url = "http://" . $url;
//--- check if the url is bigger than 40 chars ---//
if (strlen($url) > 40)
$short = substr($url, 0, 18) . "...." . substr($url, -18);
else
$short = $url;
//--- return the possible ajustments ---//
return "<a href=\"" . $url . "\" title=\"" . $url . "\" target=\"_blank\">" . $short . "</a>";
}
//--- url recognition ---//
function parse_tekst($tekst)
{
$tekst = preg_replace("/\[url\](.+?)\[\/url\]/sie", "checkurl('$1')", $tekst);
//--- some posibile other UBB codes ---//
return $tekst;
}
?>
//--- check url's on length ---//
function checkurl($url)
{
//--- url must begin with http:// or intern links will occur ---//
if (substr($url, 0, 7) != "http://")
$url = "http://" . $url;
//--- check if the url is bigger than 40 chars ---//
if (strlen($url) > 40)
$short = substr($url, 0, 18) . "...." . substr($url, -18);
else
$short = $url;
//--- return the possible ajustments ---//
return "<a href=\"" . $url . "\" title=\"" . $url . "\" target=\"_blank\">" . $short . "</a>";
}
//--- url recognition ---//
function parse_tekst($tekst)
{
$tekst = preg_replace("/\[url\](.+?)\[\/url\]/sie", "checkurl('$1')", $tekst);
//--- some posibile other UBB codes ---//
return $tekst;
}
?>