我有价格价值,其中前面有英镑符号。我需要删除该标志。PHP删除英镑符号(£)从价格
$price = '£3.76' (This comes from database and is stored as a string within the database)
1) preg_replace('/[\£]/', '', $price);
2) ltrim($price, '£');
3) str_replace(utf8_decode("£"),"",utf8_decode($price));
4) str_replace('£', '', $price);
我试图使用一切,但没有任何工作。 1和4用Â替代,2和3在值的左边添加Â。有人可以帮帮我吗。
以上哪个命令会产生您所看到的输出?请将包含价格值的完整字符串作为示例发布,以便我们有一个真实世界的示例来帮助您。 – nvisser
我现在编辑了这个问题,请让我知道现在是否更清楚。 – user4676307
如果您在浏览器中看到'',这是因为服务器发送的内容类型字符编码不正确。你可以添加'header('Content-type:text/html; charset = utf-8');'给你的脚本正确地看到井号。但'$ price = str_replace('£','',$ price);'对我来说可以很好地移除它。 – drew010