SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: minimum variable lengths
-
Nov 24, 2001, 13:10 #1
minimum variable lengths
how do i check the length of a variable?
and how do i use it in an if statement?
thanks for any help as usual
-
Nov 24, 2001, 14:19 #2
- Join Date
- Mar 2001
- Location
- Southern California, USA
- Posts
- 1,181
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you want to see if a variable has a length of 10:
if (strlen ($variable) == 10)
{
//yes it is
}
-
Nov 24, 2001, 21:04 #3
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Just a small side-note: strip the whitespace at the beginning and end of the variable, too, if you're trying to limit public user input. Example:
PHP Code:if (strlen(trim($text)) == 10) {
// do stuff
}
Bookmarks