the variable $totalamount is probably being treated as a string when its over 1000 because you have a comma in it from being number formatted above the tax part. either create separate variables that get number formatted or just output them.
example:
$totalamount = number_format($totalamount, 2);
//right there above, anything over 1000 goes from int(1000)
//to string("1,000")
...
...
...
$taxrate = 0.10; //local tax rate
$totalamount = $totalamount * (1 + $taxrate);
//the above is trying to add a string so it will just drop everything
//after the comma, to turn in into an integer
// so 1 + .10 = 1.10 as shown in your example output.
$totalamount = number_format($totalamount,2);
echo "Total including tax: $".$totalamount."<br>\n";