- is_numeric: documentation ( source)
- ctype_alpha: documentation ( source)
- preg_replace: documentation ( source)
- number_format: documentation ( source)
<?php
$number = ['1,2', 1, ''];
foreach ($number as $val) {
if (!empty($val) || !ctype_alpha($val)) echo "val: $val is_numeric ".is_numeric(number_format($val))."\n\r";
}
$number = 'abc1,2def';
$number = preg_replace("/[a-zA-Z]/i", '', $number);
echo 'is numeric? '.is_numeric(number_format($number));