html - Convert ' to an apostrophe in PHP -


my data has many html entities in (• ...etc) including '. want convert character equivalent.

i assumed htmlspecialchars_decode() work, - no luck. thoughts?

i tried this:

echo htmlspecialchars_decode('they're here.'); 

but returns: they're here.

edit:

i've tried html_entity_decode(), doesn't seem work:

echo html_entity_decode('they're here.') 

also returns: they're here.

since ' not part of html 4.01, it's not converted ' default.

in php 5.4.0, extra flags introduced handle different languages, each of includes ' entity.

this means can this:

echo html_entity_decode('they're here.', ent_quotes | ent_html5); 

you need both ent_quotes (convert single , double quotes) , ent_html5 (or language flag other ent_html401, choose appropriate situation).

prior php 5.4.0, you'll need use str_replace:

echo str_replace(''', "'", 'they're here.'); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -