Jump to content

Archived

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

gabrielserban

wrap long links

Recommended Posts

hello

i have a problem with some long links that i'm writting on my forum.

i tried to use
$message = wordwrap($message, 80, "\n", 1);
on the post body, but the second row of the link is no longer part of it

does anyone know what can i do??

thx

i'm adding a test link here to see if it's like my forum

[a href=\"http://testing.testing.com/Testing_testing_testing_testing/test_test_test_test/testing_testing_testing\" target=\"_blank\"]http://testing.testing.com/Testing_testing...testing_testing[/a]

hmmm

the name is shorted

how is this done?

in the database post.post_text doesn't have tags, only url

Share this post


Link to post
Share on other sites
Very basic example:
[code]<?php
$message = 'http://testing.testing.com/Testing_testing_testing_testing/test_test_test_test/testing_testing_testing';
$max_length = 50;
if (strlen($message) > $max_length) {
  $part1 = substr($message, 0, (($max_length / 2) - 1));
  $part2 = substr($message, -10);
  $url = $part1 . '...' . $part2;
} else {
  $url = $message;
}
  echo "<a href='$message'>$url</a>";
?>[/code]

Share this post


Link to post
Share on other sites

×

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.