Your function returns 1,423.28
? This is not a float, as a float does never contain a comma as a thousands-separator.
PHP interprets this as 1, because it "breaks" at the comma.
Remove the comma and you are fine!
$balance = str_replace(',', '', $balance);