Jump to content

wrap long links


gabrielserban

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

Link to comment
https://forums.phpfreaks.com/topic/12372-wrap-long-links/
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]
Link to comment
https://forums.phpfreaks.com/topic/12372-wrap-long-links/#findComment-47318
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.