Last active
December 1, 2021 19:26
-
-
Save kebalicious/13762b5501c650f0f7a2c046aa8ab97d to your computer and use it in GitHub Desktop.
Round Off to Nearest for MYR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$value = 0.29; | |
$getval = substr($value, -1); | |
$var = substr($value, -2, 1) + 1; | |
if ($getval <= 2) { | |
$final = substr_replace($value, 0, -1); | |
} elseif ($getval >= 3 && $getval <= 7) { | |
$final = substr_replace($value, 5, -1); | |
} elseif ($getval >= 8 && $getval <= 9) { | |
$notyet = substr_replace($value, 0, -1); | |
$final = substr_replace($notyet, $var, -2, 1); | |
} | |
// Get value on adjustment | |
$adj = preg_replace("/[^a-zA-Z 0-9 .]+/", "", ($final - $value)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment