- preg_match: documentation ( source)
- range: documentation ( source)
<?php
function is_intstr($val, $negative=false) {
return preg_match("/^".($negative?"-?":"")."(0|[1-9][0-9])*$/", $val);
}
foreach(range(0, 10) as $n) {
echo $n;
echo " - ";
echo is_intstr($n);
echo "\n";
}