is there a php function that I can verify if the string contains all digital number, not alphabetic charactor? thanks.

While I would agree with the regular expressions. It is the best and proper way. Regular expressions can be hard to make.

An alternative would be to have an array like this
$my_nums = array("0","1","2")

and then loop through the length of the string and do a check like this

if (in_array($your_string, $my_nums))

-Brad

www.azpixels.com

try

preg_replace ("#[^0-9]#i", '', $field);

which will strip out anything that isn't a number

If you're willing to allow scientific notation etc.., how about using is_numeric():

From the manual: http://us3.php.net/is_numeric

bool is_numeric ( mixed var )

Finds whether the given variable is numeric. Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal notation (0xFF) is allowed too but only without sign, decimal and exponential part.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.