- 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(-10, 20) as $n) {
echo $n*$n*$n;
echo " - ";
echo is_intstr($n*$n*$n, true);
echo "\n";
}