PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
gotDNS
Forum Contributor
Posts: 217 Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA
Post
by gotDNS » Fri Aug 16, 2002 2:59 pm
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
Elfstone
Forum Newbie
Posts: 21 Joined: Tue Jun 11, 2002 2:25 am
Location: NJ, USA
Post
by Elfstone » Fri Aug 16, 2002 3:04 pm
Code: Select all
if (strlen($yourstring) > "240") {
echo "too long";
}
gotDNS
Forum Contributor
Posts: 217 Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA
Post
by gotDNS » Fri Aug 16, 2002 3:05 pm
Thanks, dude! *progresses once again on tedious parts of a site.*
later on, -Brian
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Fri Aug 16, 2002 3:06 pm
or if you want to cut it off,
if(strlen($str) > 240){
$str = substr($str, 0, 237)."...";
}
gotDNS
Forum Contributor
Posts: 217 Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA
Post
by gotDNS » Fri Aug 16, 2002 3:10 pm
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