Check the amount of characters in a string function
<?php
//check the amount of characters in a string function
Function CheckNoChars($strText)
{
//check for between 6 and 12 characters
if (eregi(”^.{6,12}$” , $strText))
return true;
else
return false;
}
?>
<?php
//test the function
$str1 = “mypasswordistoolong”;
if (CheckNoChars($str1))
//if its OK display this message
echo “this has the correct number of characters”;
//if its not OK display this one instead
else
echo “incorrect number of characters”;
?>
Related posts:
- Highlight a string <?php $msg1 = “<?php echo \”test message to display\”; highlight_string($msg1)...
- temperature conversion function A simple temperature conversion function <?php function TempConv($temp,$corf) { ...
- Check Service Exists check if a service exists on a port using PEAR...
Related posts brought to you by Yet Another Related Posts Plugin.
Tags: ereg



















