454,705 Members | 1,350 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,705 IT Pros & Developers. It's quick & easy.

# Never liked printf, why is it doing this?

 P: n/a Why does this: .......... \$sum_value+=\$row_array[8]; } echo ""; echo "
Total Value of Orders: ".printf('\$%01.2f', \$sum_value)."
"; echo "
Done"; Result in this? \$20500.00 Total Value of Orders: 9 Done I have no idea where the '9' came from and why does @sum_value print before the string? Jul 17 '05 #1
3 Replies

 P: n/a > \$sum_value+=\$row_array[8]; } echo ""; echo "
Total Value of Orders: ".printf('\$%01.2f',\$sum_value)."
"; You want sprintf(), not printf() above. echo "
Done";Result in this?\$20500.00Total Value of Orders: 9 What is the return value of printf()? It's *NOT* a string. It's the length of the string it output. Gordon L. Burditt Jul 17 '05 #2

 P: n/a Gordon Burditt wrote: \$sum_value+=\$row_array[8];}echo "";echo "
Total Value of Orders: ".printf('\$%01.2f',\$sum_value)."
"; You want sprintf(), not printf() above. or structure it like this: printf("
Total Value of Orders: \$%01.2f
", \$sum_value); [snip] -- Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com Jul 17 '05 #3

 P: n/a *** Chris Hope wrote/escribió (Fri, 29 Apr 2005 07:41:37 +1200): You want sprintf(), not printf() above. or structure it like this: printf("
Total Value of Orders: \$%01.2f
", \$sum_value); O maybe: http://www.php.net/number_format -- -- Álvaro G. Vicario - Burgos, Spain -- http://bits.demogracia.com - Mi sitio sobre programación web -- Don't e-mail me your questions, post them to the group -- Jul 17 '05 #4

### This discussion thread is closed

Replies have been disabled for this discussion.