Forum Moderators: coopster
I have a beginner's programming knowledge and I'm trying to adapt a script to work with my site, so I wonder if any of you could help.
My script displays URLs of other sites, and I'm seeing that very long URLs don't wrap within the table, therefore pushing out the borders and spoiling the format.
Can anybody give me a piece of code that will take an URL variable (e.g. $url) and parse it to place a space after the 1st forward slash
(e.g. http://www.example.com/very/long/url/ would be replaced by http://www.example.com/ very/long/url/)
Alternatively, the space could be placed after the second slash, so that not so many URLs are changed this way.
(e.g. http://www.example.com/very/long/url/ would be replaced by http://www.example.com/very/ long/url/)
Many thanks for any indicators you can give me.
if(strlen($link) > 20) {
echo substr($link,0,20).'...';
} else {
echo $link;
}
Good luck!