摆脱美元符号?

Mat*_*iby 3 php

好的,我正在通过我正在编写的PHP脚本导入csv,电子表格的值为$ 4090,00,我需要使用PHP在mysql十进制字段中插入这些值.有没有一种简单的方法可以摆脱$ if if if in PHP

Vin*_*ard 14

使用str_replace,甚至修剪:

$str = str_replace('$', '', $str);
$str = trim($str, '$'); // only delete $ at start or end of the string
Run Code Online (Sandbox Code Playgroud)

有很多解决方案.此外,请注意您必须使用句点分隔符为小数和整数部分,而不是逗号.


Aiv*_*ler 6

$value = "$4090,00";
$value = preg_replace('/[\$,]/', '', $value);
Run Code Online (Sandbox Code Playgroud)