EnexoOnoma
EnexoOnoma

Reputation: 8836

Allow only two digits max in GET?

How do I check if there are only two digits maximum in if(++$i > $_GET['number']) break; ?

Upvotes: 0

Views: 153

Answers (2)

MRR0GERS
MRR0GERS

Reputation: 654

if (strlen($_GET['number']) > 2)
{
    ...
}

Upvotes: 3

shox
shox

Reputation: 1160

use :

$number = intval($_GET['number']) ;
if( number >= 0 && <= 99 )
{

}

//OR
if( preg_match('/^[0-9]{2}$/',$_GET['number'] )
{

}

Upvotes: 3

Related Questions