What I mostly do is something like
PHP Code:
$allValid = true;
$threshold = 255;
foreach($_POST as $var)
{
$allValid = $allValid && ( strlen($var) < $threshold );
}
The parentheses around strlen($var) < $threshold are not syntactically necessary but I like them for readability.
If you really want to know if all is good and stop as soon as one check fails you could also do
PHP Code:
$allValid = true;
$threshold = 255;
foreach($_POST as $var)
{
$allValid = $allValid && ( strlen($var) < $threshold );
// stop checking if one if the variables is too long
if (!$allValid) break;
}
The break statement tells PHP to stop the foreach loop and go on with what's beneath it (in this example nothing, but you get the point).
If you want different thresholds for different variables you could do something like
PHP Code:
$allValid = true;
// the next line is just an example of course
$checks = array('firstname' => 40, 'lastname' => 40, 'email' => 60);
foreach($checks as $var => $threshold)
{
$allValid = $allValid && ( strlen($var) < $threshold );
}
Hope that helps 
PS. I guess you already know this, but
< means smaller than
<= means smaller than or equal to
Same goes for > and >=
Bookmarks