View Full Version : numbers
bunny1
03-08-2007, 01:38 AM
Is there a method to check that a variable is a number. For ex. for price?
thanks
Nightfire
03-08-2007, 02:16 AM
is_numeric($var) (http://php.net/is_numeric)
mmarif4u
03-08-2007, 04:08 AM
u can also try this:
if ( !preg_match('/^[0-9\]*$/', $cleaned_for_sql['hp']) )
{
echo "HP Number is not Valid Please try again.";
Inigoesdr
03-08-2007, 05:06 AM
u can also try this:
if ( !preg_match('/^[0-9\]*$/', $cleaned_for_sql['hp']) )
{
echo "HP Number is not Valid Please try again.";
Using regular expressions is really not necessary here, and it is a lot slower.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.