Jump to content


Photo

wrap long links


  • Please log in to reply
1 reply to this topic

#1 gabrielserban

gabrielserban
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 19 June 2006 - 01:24 PM

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



#2 kanikilu

kanikilu
  • Members
  • PipPip
  • Member
  • 29 posts
  • LocationDallas, TX

Posted 19 June 2006 - 02:29 PM

Very basic example:
<?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>";
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users