Page 1 of 1

limit text length displayed?

Posted: Sun Feb 05, 2006 8:29 am
by jasondavis
I show a name on a page from a DB with this $user[txtMSName]
The problem is some names are so long they mess up my layout how can I limit it to20 characters then inserts a <BR> tag?

Posted: Sun Feb 05, 2006 8:32 am
by feyd
substr() is your friend.

Posted: Sun Feb 05, 2006 8:47 am
by jasondavis
thanks here is what I came up with but it outputs nothing

$username = substr("$user[txtMSName]", 4);

Posted: Sun Feb 05, 2006 9:41 am
by feyd

Code: Select all

$username substr($user['txtMSName'],0,4);

Posted: Sun Feb 05, 2006 11:59 am
by John Cartwright
I think wordwrap() is your friend here