Re: How to limit chars?
| From: | Marco Tabini | Date: | Fri, 08 Nov 2002 01:56:26 +0000 |
| Subject: | Re: How to limit chars? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123295@lists.php.net to get a copy of this message | ||
If you want to prevent the string from being posted unless the user
writes it using less than 100 characters, the function you're looking
for is strlen()
http://ca.php.net/manual/en/function.strlen.php
as in
if (strlen ($string) > 1000)
echo 'error';
Otherwise you can simply truncate the string using substr as Martin
suggested.
Marco
Marco
-------------
php|architect -- The Monthly Magazine For PHP Professionals
Come visit us on the web at http://www.phparch.com!
On Thu, 2002-11-07 at 20:53, Håkan wrote:
> Let's say I have a text field in my mysql database, and a <textarea> where I
> write whatever, and I want to limit it to 1000 chars or something like that
> before I add it to the database, I know I can do it with javascript, but
> that's so messy and I don't have time to figure that out right now :)
>
> Håkan
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>