[thelist] PHP: is_numeric... that's the question...

Tris beertastic at gmail.com
Wed Jan 17 09:34:40 CST 2007


Hi all...
I'm having probs with is_numeric...
here's the body of a function I've written...
the inout shoud be:
2 x letters
5 x numbers
eg: fr23454 / kr55555 / AP84754

Buuuut...
these are coming up as valid too?
F454354 / 4G64345 / L454345

it seems that if there's a single number in the usercode, it's accepting it...
can anyone see what I'm doing wrong? stupid tech :-(

=========================
$codeLength = strlen($usercode);
$getLast5Characters = substr($usercode, -5, 5);
$getFirst2Characters = substr($usercode, 0, 2);
$codeInt = is_numeric($getLast5Characters);
$codeAlpha = is_numeric($getFirst2Characters);
if (($codeLength == 7) && ($codeInt) && (!$codeAlpha)) {
	return "code valid";
} else {
	return "Code Invalid";
}
=========================


-- 
When a person can no longer laugh at himself, it is time for others to
laugh at him.
Thomas Szasz



More information about the thelist mailing list