Page 1 of 1

Limit $variable value to 20 characters

Posted: Sat Aug 10, 2002 5:33 pm
by DynamiteHost
How would I go about limiting the output value to 20 characters?

So when its printed, it displays only 20 chars.

Thanks :)

Posted: Sat Aug 10, 2002 6:54 pm
by volka

Code: Select all

print( (strlen($var)>20) ? substr($var, 0, 20) : $var );