You may have missed my second update. It now works for me as expected when I use this code in 2 places:
$format_main_balance = format_value(sprintf("%.2f",$main_balance
+));
DATE DESCRIPTION DEBIT CRED
+IT BALANCE
======================================================================
+==================
2017-05-01 starting balance to track character cou~ 900,
+000.00 900,000.00
2017-05-01 phone bill dsfsdfsfdsfsfsfsdfsfsfsfsfdf~ 300,000.00
+ 600,000.00
2017-05-03 Water 100,000.34
+ 499,999.66
2017-05-05 Electric Bill 900.21
+ 499,099.45
2017-06-03 debit 45678901dfsf2345678901234567890dd~ 30.32
+ 499,069.13
2017-06-03 12345678901234567890123456789034
+ 30.98 499,100.11
2017-06-03 credit 89012345678901234567890345678901~
+ 30.98 499,131.09
2017-06-03 credit dfdfd012345678901234567890345678~
+ 30.98 499,162.07
2017-06-08 Food 23.00
+ 499,139.07
2017-06-12 Cash 20.00
+ 499,119.07