2

I have a simple PHP script helping me run a number calculator and the arithmetic part of it works fine, it draws input form the databse nicely.

<?php
$Userrate = $_POST['userrate'];
$Uservalue = $_POST['uservalue'];
$Usersolution = $Userrate * $Uservalue;

echo "<input name='Solution' style='width: 393px' type='text' value='$Usersolution' />"

?>

What I'm wondering is if I can apply a value to the generated text box to display the results in the [$MWK] #,##0.00 format. That is, so that instead of displaying 9000 as it does now, it displays MWK9,000.00

I've read its possible with Javascript but I'm trying to find an HTML application. Any help?

2

1 Answer 1

8

It is done with number_format function and some concatenation

echo $mvk.number_format($number, 2, '.', ',');

Note that last two arguments have . and , as a default values and can be omitted

http://php.net/manual/en/function.number-format.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.