Jump to content

printf inside email message


CanMan2004

Recommended Posts

Hi all

I have a webpage which does a number of calculations, such as VAT % and so on, when I print any number value of any of the calculations, I use

[code]printf ("%.2f", $query);[/code]

and that formats the calculated value, such as 452.34, which is great. If I use just print the query such as

[code]print $query;[/code]

then I get a value such as 452.3423

What I want to do is to create an email message which gets sent out with some of the values on it, to add content to the email message im writting, I have to put it between

[code]$message .= "";[/code]

How can I put the printf code inbetween my email message tags?

The result should look like

[code]$message .= printf ("%.2f", $query);[/code]

but that gives me an error.

Can anyone help?

Thanks in advance

Dave
Link to comment
https://forums.phpfreaks.com/topic/36124-printf-inside-email-message/
Share on other sites

I think you are looking for number_format()

[url=http://nz2.php.net/manual/en/function.number-format.php]http://nz2.php.net/manual/en/function.number-format.php[/url]

printf() is used to print and format - looks like you just want to format the number and assign it to the $message variable.....

;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.