There are a number of solutions.
Do you need to work with negative integers as well?
function specialFormat($num) {
//assume non-negative integers
if ($num <= 0) {
return 0;
}
elseif ($num < 100) {
return 100;
}
else {
$temp = substr((string)$num, 0, 3);
$num = (int)$temp;
$num /= 100;
return ceil($num) * 100;
}
}
It might also be possible to use:
return ceil(substr($num, 0, 3) / 100) * 100;
In the last else block, or at least
return ceil((int)substr((string)$num, 0, 3) / 100) * 100;