I've got a string, that is UTF-8 encoding according to mb_detect_encoding(). I want to trim like this:
$string = trim($string);
But it has no effect.
When I look at the string with urlencode($string) it displays:
"++++++++++++++++String+more+text++++++++++++"
According to: https://markushedlund.com/dev/trim-unicodeutf-8-whitespace-in-php/ I tried this code, but no effect:
preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $string);
How do i trim this? How can I find what the space character stands for and then replace it. All I know is urlencode, but this just tells me it's a space by showing +++.
Update: Thanks to @Stefanov.sm in the comments below, I learned that you can output the string to hex with: bin2hex($string); Then I see a whole lot of 20202020 and I see 20 stands for space in UTF-8 encoding. Strange though the trim won't work, but what does is:
$string = str_replace("\x20","",$string);
Maybe I can figure this out why. But at least the objective to get rid of them is completed.