I have a pretty simple PHP question but I\'m not sure how to do that.
I want to round to the max hundred or thousand depending on the value returned by the database
Final implementation, inspired from Shaunkak's answer and SO's comment. Thanks for these bra..s. live demo
= 1000) { echo ceil($val / 1000) * 1000; } else { $length = strlen(ceil($val)); $times = str_pad('1', $length, "0"); echo ceil($val / $times) * $times; }