Jump to content

[SOLVED] substr trouble


chooseodie

Recommended Posts

Hi;

When i enter these codes

 

$lasttw = "<a href=\"$row[fullurl]\">$row[fullurl]</a><br />"; 
$lasttwshort = (strlen($lasttw)>53)?substr($lasttw,0,53).'...<br />':$lasttw; 
echo "$lasttwshort"; 

 

or

 

$lasttw = "<a href=\"$row[fullurl]\">$row[fullurl]</a><br />"; 
if (strlen($lasttw) > 53) { 
  $lasttw = substr($lasttw, 0, 53) . "...<br />"; 
} 
echo "$lasttw"; 

 

i'm getting page like this;

 

http://www.yahoo.comhttp://www.youtu...
http://www.foru...
http://www.sitepoin...
http://http...
http://www.boardz...
http://www.gamezo...
http://rapidshare.dehttp://killervide.com...
http://www.forum...
http://www.forum...
...
...
http://
...

 

but i wanna get page like this;

 

http://www.yahoo.com/
http://www.sitepoint.com/forums/newthread.php?do=newt...

etc

 

 

(if the link is longer than 53 chars substr should add "..." automatically)

 

Thanks for your help...

Link to comment
https://forums.phpfreaks.com/topic/43125-solved-substr-trouble/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.