Possible Duplicate: How to print a number with commas as thousands separators in JavaScript
I am trying to get the value in this format, $1,000,000
. Right now I am getting the value in this format, 1000000
, and it's working fine, but I don't want this. I want it to get the value as $1,000,000 and change it in my PHP code and accept it.
My HTML:
<form action="index.php" method="Get">
Enter the present value of pet: <input type="text" name="v" value="1000000"/><br>
Enter the value of the pet you want: <input type="text" name="sv" value="1951153458"/><br>
<input type="submit" />
</form>
And here is my PHP:
<?php
$i = 0;
$v = isset($_GET['v']) ? (float) $_GET['v'] : 1000000;
$sv = isset($_GET['sv']) ? (float) $_GET['sv'] : 1951153458;
$petearn = 0;
$firstowner = 0;
$secondowner = 0;
And so on..............
My calculator is working fine in this way:
http://ffsng.deewayz.in/index.php?v=1000000&sv=1951153458
But I want it to be:
http://ffsng.deewayz.in/index.php?v=$1,000,000&sv=$1,951,153,458
I'm confused anout how to change this format $1,000,000
to 1000000
this
or if there is other way. Do I need to use any JavaScript code? Before the form is submitted?
Someone tried to help me the following way, but I have no clue on how to use it.
function reverse_number_format($num)
{
$num = (float)str_replace(array(',', '$'), '', $num);
}