Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Zero-width non-joiner from string?

I have one string in PHP script

$str="इन रिकॉ‌र्ड्स पर है सलमान की नजर, धूम-3 को पछाड़ेगी जय हो?";

and converting it from below code:

$encoded_string = bin2hex(mb_convert_encoding($str, "UTF-16BE", 'UTF-8'));

Output at Mobile Device :

इन रिकॉ‌(Here Zero-Width Non-Joiner is displaying in output)र्ड्स पर है सलमान की नजर, धूम-3 को पछाड़ेगी जय हो?

but getting Zero-Width Non-Joiner ** in final output. how can i will remove this entity while converting string not after getting final output?

like image 883
Explorer Avatar asked Feb 14 '26 09:02

Explorer


2 Answers

found Solution , Just replace Zero-Width Non-Joiner entity from String and it will works.

 $str=str_replace('‌','',$str);

     **OR**  

 $str=str_replace('‌','',$str;
like image 130
Explorer Avatar answered Feb 16 '26 00:02

Explorer


$content = preg_replace( '/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $content );
like image 25
laugh Avatar answered Feb 16 '26 00:02

laugh