PHP trim () doesn't crop space

I got a strange problem. I am trying to trim a string using php trim(), but it does not work.

Here is my code

echo $deal->{self::DEAL_BUSINESS};
echo '<br>';
echo trim($deal->{self::DEAL_BUSINESS});
echo '<br>';

And here is the conclusion

 Alkaram Studio
 Alkaram Studio

If the output is not visible. There is a space at the beginning of both the uncrop and trimmed lines.

In the original view, I got this.

&nbsp;Alkaram Studio
+4
source share
1 answer

Try the following:

echo trim($deal->{self::DEAL_BUSINESS}, "\xC2\xA0\n");

Or

$text = preg_replace('~\x{00a0}~siu','',$deal->{self::DEAL_BUSINESS});
echo $text;
+5
source

All Articles