skip to Main Content

need help with tax calculation displaying

tax cal code

$vat = 7.75;
$taxesOnly = ($val['quantity'] * $val['price'] / 100) * $vat;

result: $51.925

what i want: $51.92

thank you in advance

2

Answers


  1. you can use round($taksesOnly) like this code

    $val = array(
                 'quantity' => 1,
                 'price' => 50
                ); 
    $vat = 7.75;
    $taxesOnly = ($val['quantity'] *$val['price'] / 100) * $vat;
    echo round($taxesOnly,2);
    
    Login or Signup to reply.
  2. $vat = 7.75;
    $taxesOnly = ($val['quantity'] * $val['price'] / 100) * $vat;
    return number_format($taxedOnly,2,'.',',');
    

    this will return you two digit of decimal , or if you want to make changes accordingly based on currency & decimal separators.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search