这是我在 Stackoverflow 的第一个问题,所以请多多包涵:)
过去几个小时我一直在尝试做的是替换从数据库上传和下载的符号。
How it should be:
Input: 100.000,25
Stored in database: 100000.25
Output: 100.200,25
原因是我需要逗号作为小数分隔符,点作为千位分隔符。我仍然需要能够添加/乘以存储在数据库中的数字等等。
到目前为止,我尝试过的最好的方法是:
// Value from form input:
$value = 100.200,25;
// Removing all but numbers and comma
$remove_symbols = array("+"," ",".","-","'","\"","&","!","?",":",";","#","~","=","/","$","£","^","(",")","_","<",">");
$db_value = str_replace($remove_symbols, '', $value);
// $db_value insert into db
// Pulling out the data
$db_pulled = number_format($row['liter'],2,',','.');
echo $db_pulled;
:( returns: 100.200,00 (should return 100.200,25)