Search
Syndication
Sponsors

Check the amount of characters in a string function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)


<?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:

  1. Highlight a string <?php $msg1 = “<?php echo \”test message to display\”; highlight_string($msg1)...
  2. temperature conversion function A simple temperature conversion function <?php function TempConv($temp,$corf) {    ...
  3. 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:

Leave a Reply