Reputation: 6217
I have zipcodes being outputted, coming from user inputted values. Looks like it is outputting zero-width-space \u200b
sometimes at the beginning of the strings.
What is the best way to replace these from within php before echoing the variable?
Upvotes: 2
Views: 3872
Reputation: 15629
I use this function to trim unicode spaces - this should work in your case too.
function trimUnicode($str) {
return preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u','',$str);
}
Upvotes: 4
Reputation: 6217
Ok, seems as though this was coming from the actual string being echo'd by PHP, so I did the following to the string:
$zipcode = trim(utf8_decode($zipcode), '?');
All seems fine now!
Upvotes: 3