CanMan2004 Posted January 29, 2007 Share Posted January 29, 2007 Hi allI 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.3423What 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 advanceDave Link to comment https://forums.phpfreaks.com/topic/36124-printf-inside-email-message/ Share on other sites More sharing options...
matto Posted January 29, 2007 Share Posted January 29, 2007 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..... ;) Link to comment https://forums.phpfreaks.com/topic/36124-printf-inside-email-message/#findComment-171534 Share on other sites More sharing options...
spfoonnewb Posted January 29, 2007 Share Posted January 29, 2007 Make it equal to a varaible, and send the variable?[code]<?php$query = "383828";$messageinfo = printf ("%.2f", $query);$message = "This is your number... $messageinfo";mail('[email protected]', 'My Subject', $message);?>[/code] Link to comment https://forums.phpfreaks.com/topic/36124-printf-inside-email-message/#findComment-171536 Share on other sites More sharing options...
CanMan2004 Posted January 29, 2007 Author Share Posted January 29, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/36124-printf-inside-email-message/#findComment-171545 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.