PHP function to check lenght of string
0This was the first function I ever wrote and I still use it in nearly every PHP application I create.
function checkLength($name, $low, $high, $which) {
global $error; // This global returnes any errors out of the function
if (strlen($name) < $low) {
$error[] = "<b>{$which}:</b> Must be between {$low} and {$high} characters."; }
if (strlen($name) > $high) {
$error[] = "<b>{$which}:</b> Must be between {$low} and {$high} characters."; }
}Tags: validation, form, functions
