3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function floor_dec($number,$precision = 2,$separator = '.') { $numberpart=explode($separator,$number); $numberpart[1]=substr_replace($numberpart[1],$separator,$precision,0); if($numberpart[0]>=0) { $numberpart[1]=substr(floor('1'.$numberpart[1]),1); } else { $numberpart[1]=substr(ceil('1'.$numberpart[1]),1); } $ceil_number= array($numberpart[0],$numberpart[1]); return implode($separator,$ceil_number) . "0"; } echo floor_dec(0.78, 1, ".");
based on sARlS
Output for 5.6.0 - 5.6.30, hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.2.6
0.70