- is_numeric: documentation ( source)
<?php
$tests = array(
"42",
1337,
"1e4",
"not numeric",
9.1,
'234ffffdsf'
);
foreach ($tests as $element) {
if (is_numeric($element)) {
echo "'{$element}' - число", PHP_EOL;
} else {
echo "'{$element}' - НЕ число", PHP_EOL;
}
}