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
CTYPE [message #182663] Sun, 25 August 2013 17:51 Go to previous message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma:
Senior Member
Hi all,

I'm still working on the postal code issue, for Canada at the moment and
I'm still stuck.

I've decided to try:
= See if it's alpha-numeric
= Create an array
= See if there is a space where it belongs
= Validate for digits in proper positions
= Since it's alpha-numeric, the 3 characters left must be Alphabetic.
If the validations work, keep going.
If not, halt & allow for a re-entry.

The ctype statement will NOT work in any form and throws various errors
regardless of wher I place it or what I use s the var. Remove the entire
ctype, and everything works again.

In code, this equates to, as best as I can:
--------------------------------------------------------------------------- ------------------------
IF(strlen($zip) === 7) {
echo "Zip appears to be Canadian . <br />";
}
// ================== NOW LOOK TO SEE IF IT'S ALPHA-NUMERIC

* if (ctype_alnum(str_split($zip,1)) { <---- Throws error [1]
* echo "Is Alpha Numeric.";
*}

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

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

[1] : Error is:
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\twa1.php on
line 107
Line 107 is:
echo "Zip appears to be Canadian . <br />";
--------------------------------------------------------------------------- ----------------------
I have tried various forms of the ctype statement, where it's shown here
and lower in the code after the array is generated, and using $zip[0] .
$zip[3]... etc. I simply can not get any form of the ctype statement
working and I have a LOT of sample code I've collected from several
sources, all not quite what I need.
--------------------------------------------------------------------------- ----------------------

If I change the code & location as follows:
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)); <--------------- LINE 114
echo '</pre>';

if (ctype_alnum(($zip[0]))
echo "Is Alpha Numeric.";

// ================= check space where it belongs
if($zip[3] === " ") {
echo "Space in correct place<br />";
}
--------------------------------------------------------------------------- ------------------
It still throws an error as:
Parse error: syntax error, unexpected T_ECHO in C:\xampp\htdocs\twa1.php
on line 114


What the heck am I doing wrong? Any advice appreciated; I can't believe
I can't get ctype to work; it seems so simple!

TIA,

Twayne`
[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: Sat Sep 14 22:21:35 GMT 2024

Total time taken to generate the page: 0.04711 seconds