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:
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
35 / 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
« Next Oldest Return to Top Next Newest »

Messages In This Thread
PHP help ... again - by absorbation on 07-03-2006 at 06:42 PM
RE: PHP help ... again - by Plik on 07-03-2006 at 06:51 PM
RE: PHP help ... again - by absorbation on 07-03-2006 at 06:53 PM


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