<?php
$tax = bcmul("33.95", ".065", 3); // 2.20675
$real_total = bcadd("33.95", "7.87", 3); // 41.82
$real_total = bcadd($real_total, $tax, 3); // 44.02675
echo mask("4111 1111 1111 1111", -4);
function bcround($number, $scale = 0) {
$fix = "5";
for ($i=0; $i<$scale; $i++) $fix = "0$fix";
$number = bcadd($number, "0.$fix", $scale + 1);
return bcdiv($number, "1.0", $scale);
}
function mask($string, $start = 0, $length = false) {
$mask = preg_replace('/([\w])+/', '*', $string);
if (!$length) {
$mask = substr($mask, $start);
$string = substr_replace($string, $mask, $start);
} else {
$mask = substr($mask, $start, $length);
$string = substr_replace($string, $mask, $start, $length);
}
return $string;
}
preferences:
55.2 ms | 402 KiB | 5 Q