Jump to content

Recommended Posts

Did you read the documentation for html_entity_decode(). It tells you what a   is converted to -

Notes

Note: You might wonder why trim(html_entity_decode(' ')); doesn't reduce the string to an empty string, that's because the ' ' entity is not ASCII code 32 (which is stripped by trim()) but ASCII code 160 (0xa0) in the default ISO 8859-1 characterset.

 

EDIT PFMaBiSmAd already answered this. But, I'll post this nonetheless since I provided a code solution

 

Well, a non-breaking space (i.e.  ) is a different character than a breaking-space.

 

The typical space character that allows line breaking is ASCII code 32, wherease the   converted to a single character space is ASCII character 160.

 

So you could either echo a non-breaking space character to the page and copy/paste that into your str_replace, or use the character code equivalent.

 

str_replace(chr(160), "", $string)

I am sorry to late reply, my internet connection was down last night ..

 

Did you read the documentation for html_entity_decode(). It tells you what a   is converted to -

Notes

Note: You might wonder why trim(html_entity_decode(' ')); doesn't reduce the string to an empty string, that's because the ' ' entity is not ASCII code 32 (which is stripped by trim()) but ASCII code 160 (0xa0) in the default ISO 8859-1 characterset.

 

I did read that line before posting here but i didn't understand the significance. I though that note was applicable for trim function, not str_replace function. So, I was wondering whether there is any solution to remove   once I use html_entity_decode, unless I go back using htmlentities().

 

EDIT PFMaBiSmAd already answered this. But, I'll post this nonetheless since I provided a code solution

 

Well, a non-breaking space (i.e.  ) is a different character than a breaking-space.

 

The typical space character that allows line breaking is ASCII code 32, wherease the   converted to a single character space is ASCII character 160.

 

So you could either echo a non-breaking space character to the page and copy/paste that into your str_replace, or use the character code equivalent.

 

str_replace(chr(160), "", $string)

 

Thanks very much, i was looking exactly for this. :)

 

Thanks everybody.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.