too long

and it's driving me nuts. I tried everything. I have two strings.

The first one Allee 4 The second one  4

These are the regexxes I tried

$a = preg_replace ( "#\&nbsp\;#u", " ", $address[1]);
$a = preg_replace ( "#\&nbsp\;#", " ", $address[1]);
$a = preg_replace ( "# #u", " ", $address[1]);
$a = preg_replace ( "# #", " ", $address[1]);

None of them worked. The string always stayed  4. Am I missing something?

Of course I already save the replacement into a variable...

Give this one a shot:

$address[1] = html_entity_decode($address[1]);
$address[1] = preg_replace("/\s/",'',$address[1]);
echo $address[1];

If it's working, do this to re-encode:

html_entities($address[1]);

preg_replace does not operate in place. It returns result so you must do:

$address[1] = preg_replace ( "#\&nbsp\;#u", " ", $address[1]);
$address[1] = preg_replace ( "#\&nbsp\;#", " ", $address[1]);
$address[1] = preg_replace ( "# #u", " ", $address[1]);
$address[1] = preg_replace ( "# #", " ", $address[1]);

I believe you need to use:

$address[$i] = preg_replace("/ /", "", $address[1]);

You need to delimit regexes with //. Not sure if & or ; are escape characters, but I think not in this context.