2

In the following code:

$string1 = "function doesn't work as expected";
$string2 = html_entity_decode($string1);

$string2 still contains:

 '

...after the call to html_entity_decode().

I've checked other SO threads on this topic, but haven't yet found the answer. What am I missing?

1 Answer 1

7

The default flags for html_entity_decode do not include single quotes. Try updating your flags argument to include ENT_QUOTES and ENT_HTML5:

$string1 = "function doesn't work as expected";
echo $string2 = html_entity_decode($string1, ENT_QUOTES|ENT_HTML5);
// function doesn't work as expected
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.