Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problem dissecting string
Old 12-18-2007, 02:48 PM Problem dissecting string
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
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($link0$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
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 12-18-2007, 03:02 PM Re: Problem dissecting string
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
$link = substr($url, 0, $linkLength);
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-18-2007, 03:36 PM Re: Problem dissecting string
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Thanks, I realised that I had that originally [only forgot to change it back after trying to debug it] and so it didn't fix it.

Then I realised, thats what the link actually was in the database! Arghhhh what a waste of half an hour!

Thanks for the help anyway.
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Reply     « Reply to Problem dissecting string
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13772 seconds with 12 queries