$num_length = strlen((string)$num);if($num_length == 10) { // Pass} else { // Fail}
if (preg_match('/^\d{10}$/', $string)) { // pass} else { // fail}
This will work for almost all cases (except zero) and easily coded in other languages:
$length = ceil(log10(abs($number) + 1)