Php remove space from integer

I have string like this:

$str = "old iccid : 809831 3245 345 new iccid : 999000 112221"

How to remove the space character between number character in PHP, to become this output?

$output = "old iccid : 8098313245345 new iccid : 999000112221";

Justin

1,7814 gold badges18 silver badges40 bronze badges

asked Aug 13, 2012 at 5:25

1

Separate the digits from characters and use

$str="809831 3245 345";
$foo= str_replace[' ','',$str];
echo $foo; // gives 8098313245345

answered Aug 13, 2012 at 5:38

Bhuvan RikkaBhuvan Rikka

2,6831 gold badge16 silver badges27 bronze badges

3

UPDATE: this is NOT the answer. See comments.

$output = preg_replace[ '/\d[ *]\d/', '', $str];

answered Aug 13, 2012 at 5:45

minboostminboost

2,5451 gold badge14 silver badges15 bronze badges

3

I've got the answer from xdazz [//stackoverflow.com/users/762073/xdazz], this syntax works well.

$output = preg_replace['/[?

Chủ Đề