Jump to content

is it a digit?


mkosmosports

Recommended Posts

You could alternatively use:
[code]
$input = '88';
$match = preg_match("/^[0-9]+$/",$input);
if( $match )
{
  //wow, it is a number
}
[/code]

This version will check that it is a single digit (0-9):
[code]
$input = '88';
$match = preg_match("/^[0-9]{1}$/",$input);
if( $match )
{
  //wow, it is a single digit
}
[/code]

Or to simply check it is a number:
[code]
if( is_numeric( $input ) )
{
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/34948-is-it-a-digit/#findComment-164801
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.