FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » CTYPE
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: CTYPE THREAD RESOLVED [message #182670 is a reply to message #182663] Sun, 25 August 2013 19:35 Go to previous messageGo to previous message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma:
Senior Member
If anyone is interested, here's the code I ended up with. It still
needs to validate alphabetic & numeric array positions but that should
be reasonably simple to add by checking the array positions for alpha or
digit characters.

Thanks for all the help!
-----------------------------------
$zip = check_input($zip);
$zip = strtoupper($zip);
// DETERMINE IF US POSTAL CODE
if(strlen($zip)===5) {
echo "U.S. postal code used "; }
IF (is_numeric($zip)) {
echo " and is 5 digits.";
}
IF(strlen($zip) === 7) {
echo "Zip appears to be Canadian . <br />";
}
// ================== NOW LOOK TO SEE IF IT'S ALPHA-NUMERIC

// ================ LET'S ASSIGN IT TO AN ARRAY
echo ' <pre>';
print_r(str_split($zip,1));
echo '</pre>';

// ================= check space is where it belongs
if($zip[3] === " ") {
echo "<br />Space in correct place<br />";
}

$sUser = $zip;
$aValid = array(' ');
if(!ctype_alnum(str_replace($aValid, '', $sUser))) {
echo "Username has a problem";
echo 'Your Postal Code is NOT properly formatted.';
}
else {
echo "Postal code is properly formatted as ALPHA NUMERIC with ONE SPACE
as the 4th character";
}
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: korean character sets
Next Topic: Android app Developers requirements
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 08:38:38 GMT 2024

Total time taken to generate the page: 0.06255 seconds