Page 1 of 1
How to see if a string is too long.
Posted: Fri Aug 16, 2002 2:59 pm
by gotDNS
Ok, now that i can get the length of a string: how would i dosomething like:
if the length of the string is over 240 characters: echo "too long.";
That as an example...but how might i do that?
thanks
Posted: Fri Aug 16, 2002 3:04 pm
by Elfstone
Code: Select all
if (strlen($yourstring) > "240") {
echo "too long";
}
Posted: Fri Aug 16, 2002 3:05 pm
by gotDNS
Thanks, dude! *progresses once again on tedious parts of a site.*
later on, -Brian
Posted: Fri Aug 16, 2002 3:06 pm
by hob_goblin
or if you want to cut it off,
if(strlen($str) > 240){
$str = substr($str, 0, 237)."...";
}
Posted: Fri Aug 16, 2002 3:10 pm
by gotDNS
ooo, thankee very much! I can use such information in 2 places!
*improves site layout by cutting back on the length of an entry...*
Thanks!
later on, -Brian