Ask Your Question
0

How can the Unicode Zero Width Space be eliminated in PHP?

asked 2021-05-14 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2021-04-09 22:00:00 +0000

scrum gravatar image

To eliminate the Unicode Zero Width Space in PHP, you can use the str_replace function to replace it with an empty string.

Here's an example:

$string = "Hello​ World!"; // has zero width space after 'o'
$newString = str_replace("\u{200b}", "", $string);
echo $newString; // outputs "Hello World!"

In this example, we use the \u{200b} escape sequence to represent the Zero Width Space character and replace it with an empty string. The resulting string will not contain the Zero Width Space.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-05-14 11:00:00 +0000

Seen: 28 times

Last updated: Apr 09 '21