Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replace   characters that are hidden in text

Tags:

regex

php

unicode

How to remove   (that are hidden) and SPACES in below text but

  • hold UNICODE characters
  • hold <br> tag

i tested:

  • i used trim($string) => NOT WORKED
  • i used str_replace('&nbsp;', '', $string) => NOT WORKED
  • i used some regex => NOT WORKED

                <br>تاريخ ورود: یکشنبه ۲۳ بهمن ماه ۱۳۹۰ 

UPDATE: Image of hidden   Thanks

like image 705
Behnam Avatar asked Mar 26 '12 11:03

Behnam


People also ask

What does it replace mean?

1 : to restore to a former place or position replace cards in a file. 2 : to take the place of especially as a substitute or successor. 3 : to put something new in the place of replace a worn carpet.

What is the synonym of replace?

Some common synonyms of replace are displace, supersede, and supplant.

How do we use Replace in English?

replace verb [T] (CHANGE FOR)to take the place of something, or to put something or someone in the place of something or someone else: The factory replaced most of its workers with robots. Tourism has replaced agriculture as the nation's main industry.


1 Answers

This solution will work, I tested it:

$string = htmlentities($content, null, 'utf-8'); $content = str_replace("&nbsp;", "", $string); $content = html_entity_decode($content); 
like image 50
Mostafa M Avatar answered Sep 23 '22 13:09

Mostafa M