Showing posts with label PHP Length Validator. Show all posts
Showing posts with label PHP Length Validator. Show all posts

Tuesday, 2 June 2015

PHP: Length validator Validates the length of a string

<?php 
function validateLength($string, $minlength=5, $maxlength=30) {
 if (strlen($string) >= $minlength && strlen($string) <= $maxlength) 
return true;
 return false; 
 } 
?>


Usage


$string - (str) the string you wish to validate.

$minlength - (int) set to 0 for no minimum length.

$maxlength - (int) sets the maximum valid length of the string




Boolean return