Hi Guys,
How do i check to see if a variable contains 8 numbers. For example.
If $dob == 8 numbers then
echo works
else
echo wrong
Has to be numbers and no text, Any help would be great.
Thanks Guys!
Hi Guys,
How do i check to see if a variable contains 8 numbers. For example.
If $dob == 8 numbers then
echo works
else
echo wrong
Has to be numbers and no text, Any help would be great.
Thanks Guys!
[FPHP]is_int[/FPHP], [FPHP]strlen[/FPHP]
I’d use [fphp]ctype_digit[/fphp] instead of is_int, in case it comes from $_POST of $_GET and is thus a string, and not an int, but numeric nonetheless
Hi StarLion,
Hope your well today. I’ve tried that but keep getting the is not integer error.
<?php
$dob=$_GET['dob'];
if (is_int($dob)) {
echo "is integer\
";
} else {
echo "is not an integer\
";
}
?>
/testdob.php?dob=4
Thanks
Ah, I’ll try this then since thats what I’m doing
Thank you.
Thanks guys, EDITED: Fixed it
Is 87654321
an acceptable value for $dob
?
No its not but its just an example
I’ve already coded it to ensure the date entered is valid
Thanks for pointing it out though.