Posts: 876
Name: Matt Pealing
Location: England, north west
|
I coded a script almost identical to this one on another page, and for some reason this isnt working properly! Can anyone see any problems with it? Maybe Ive been looking at my screen too long:
PHP Code:
<?php function makeLink($url) { global $linkLength; if(strlen($url)>$linkLength) { $link = substr($link, 0, $linkLength); $link = $link.'...'; } else { $link = $url; } $linkNew = '<a href="'.$url.'" target="_blank">'.$link.'</a>'; return $linkNew; } ?>
A url is supposed to be passed to the function, which then cuts down the text that is displayed if its over a certain amount, so that HTML for the link should look something like the following:
Code:
<a href="www.reallylongurl.com">www.reallylo...</a>
but instead Im getting this:
Code:
<a href="www.reallylo">www.reallylo</a>
Please help me someone! Thanks 
|