Special number function

Is there any function out there or someone can create a function that will strip numbers from 10 to 10 or 100 to 100 and replace them with something else ? I mean if the value is from 30 to 39 should be replaced as 30+ and so on…
I’m looking for a function to replace my current way of viewing some stats on my articles. Im currently using the default " . number_format($variable) . "

You could just do something like this, optionally wrap it in a function somewhere for easier reuse

[php]echo floor($number/10)*10 . ‘+’;[/php]

I’ve tried this and always i get 0+ as result

Which numbers did you try?

[php]$numbers = [10, 15, 22, 26, 35];

foreach($numbers as $number) {
var_dump(floor($number/10)*10 . ‘+’);
}[/php]

string(3) "10+" string(3) "10+" string(3) "20+" string(3) "20+" string(3) "30+"

note: changed ceil to floor to get your desired result. Either way shouldn’t give you 0+ all the time though

Sponsor our Newsletter | Privacy Policy | Terms of Service