- preg_match: documentation ( source)
- print_r: 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) {
print_r(is_intstr($n));
}