如何删除空白在php中,即使它没有检测到


How to remove a whitespace in php even if its not detected

我试图从字符串中删除空白,但未检测到此空白,我尝试了许多解决方案,如str_replace(), preg_replace(), htmlentities()html_entity_decode(),但它不起作用,因为我无法检测到此空白,即使它真的存在。

有什么想法吗?

示例:7412148 ==>目标:7412148PS:我已经尝试将其转换为INT(不工作)!

谢谢

让我们使用preg_replace来替换/删除所有非数字的内容。

$str = "1234 5657"; // this is an example
$number = preg_replace("/[^0-9]/","",$str);
print $number;