<?php
function round_tens($n){
$m = $n%10;
$result = $n-$m;
if ($m >= 5) {
$result += 10;
}
return $result;
}
echo round_tens(32) ."<br>";
echo round_tens(45) ."<br>";
echo round_tens(151) ."<br>";
//-----------------------
// Output
// 30
// 50
// 150
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.