Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.