PHP删除随机数字标签(\ t)

时间:2014-11-04 22:15:51

标签: php

我似乎遇到了字符串替换问题

$vals= "1/5/2012    $4,510.64 
";  //simulating web entry that would be copied and pasted from excel.
$vals = str_replace(array("\t"), " ", $vals);
echo $vals;

1/5/2012 $ 4,510.64 13257216001415138792

修剪相同

$vals= "1/5/2012    $4,510.64 
";
$vals=trim(preg_replace('/\t+/', ' ', $vals));
echo $vals;

1/5/2012 $ 4,510.641325721600

但是如果我告诉它不要用空格替换制表符,而是删除它们,那么它就不会添加任何垃圾。

$vals= "1/5/2012    $4,510.64 
";
$vals=trim(preg_replace('/\t+/', '', $vals));
echo $vals;

1/5/2012 $ 4,510.64

一点帮助?我希望标签可以替换为空格,而不会在最后添加随机数字。感谢

0 个答案:

没有答案