我正在尝试以这种格式获取值,$1,000,000
. 现在我得到了这种格式的值,1000000
它工作正常,但我不想要这个。我希望它的价值为 1,000,000 美元,并在我的PHP代码中更改并接受它。
我的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>
这是我的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..............
我的计算器以这种方式工作正常:
http://ffsng.deewayz.in/index.php?v=1000000&sv=1951153458
但我希望它是:
http://ffsng.deewayz.in/index.php?v=$1,000,000&sv=$1,951,153,458
我很困惑如何将此格式更改$1,000,000
为此1000000
或是否有其他方式。我需要使用任何 JavaScript 代码吗?在提交表格之前?
有人试图通过以下方式帮助我,但我不知道如何使用它。
function reverse_number_format($num)
{
$num = (float)str_replace(array(',', '$'), '', $num);
}