Checking the length of a trimmed string : trim « String « PHP






Checking the length of a trimmed string

 
<?
    $zipcode = trim("12344");
    $zip_length = strlen($zipcode);
    if ($zip_length != 5) {
        print "Please enter a ZIP code that is 5 characters long.";
    }
?>
  
  








Related examples in the same category

1.Combining trim() and strlen()
2.string trim ( string str [, string trim_chars] ) strips spaces, new lines, and tabs
3.trim() function removes all whitespace from both sides of string