18.06.2016, 02:49
Would this code work ?
PHP код:
stock IsIP(ip[], size=sizeof(ip))
{
new dots = 0, nums = 0, other = 0;
for(i = 0; i < size, i++)
{
switch(ip[i])
{
case '.':
{
dots++;
}
case '0'..'9':
{
nums++;
}
default:
{
other++;
}
}
}
if(dots < 3 || nums > 12 || other != 0) return 0;
else return 1;
}