chooseodie Posted March 17, 2007 Share Posted March 17, 2007 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 More sharing options...
chooseodie Posted March 17, 2007 Author Share Posted March 17, 2007 finally i go it with this code; $fullurl = $row["fullurl"]; if (strlen($fullurl) > 53) { $showurl = substr($fullurl, 0, 53) . "..."; }else{ $showurl = $fullurl; } $lasttw = "<a href=\"$fullurl\">$showurl</a><br />"; echo "$lasttw"; Link to comment https://forums.phpfreaks.com/topic/43125-solved-substr-trouble/#findComment-209461 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.