What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP help ... again

PHP help ... again
Author: Message:
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
O.P. PHP help ... again
After that script I had trouble with, the problem was sloved by a typo after like 2 hours so I am a little pissed off atm. Anyway can someone give me a function name for taking a peice of text (like http://reallllllllllllllllllylonglink.com) and change it to (http://reallllllllll...), what function would I use for this? :P Thanks :)
07-03-2006 06:42 PM
Profile PM Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
34 / Male / –
Joined: Jun 2004
RE: PHP help ... again
Heres a quick function i made.
All it does is take X chars from your string using substr and then sticks something on the end
code:
function shorten($string, $chars, $append = '...'){
   return substr($string, 0, $chars) . $append;
}
Params:
$string - The string you want shortened
$chars - The output length (not including what you stick on the end)
$append (optional) - What you want put on the end, defaults to ...

Examples
echo shorten('foobar', 3);
will output "foo..." (without quotes)

echo shorten('eljelly really rocks', 8, 'sucks');
will ouput "eljelly sucks" (without quotes)

This post was edited on 07-03-2006 at 06:58 PM by Plik.
07-03-2006 06:51 PM
Profile PM Find Quote Report
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
O.P. RE: PHP help ... again
quote:
Originally posted by Plik
substr

Thats the word I needed, and now I have my script done. H-Master just told me on messenger. Thanks for your help though :).
07-03-2006 06:53 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On