Torrie Posted July 13, 2015 Share Posted July 13, 2015 Hello friends! Miss me? :-) I can't get html characters to decode properly. Please help me at least get this to work: The "html character" for an apostrophe is this: ' How do I turn this: ' into this: ' Here is "pseudo-code" to help clarify the type of answer I want: Hi Christy, here is your answer: <?php $character = '''; $decoded = magic_decoder_function($character); echo $decoded; ?> Thank you, Hugs and kisses, -Torrie Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 13, 2015 Share Posted July 13, 2015 http://php.net/manual/en/function.html-entity-decode.php http://php.net/manual/en/function.htmlspecialchars-decode.php Quote Link to comment Share on other sites More sharing options...
Q695 Posted July 13, 2015 Share Posted July 13, 2015 Look into: http://www.w3schools.com/php/func_string_str_replace.asp Quote Link to comment Share on other sites More sharing options...
Torrie Posted July 13, 2015 Author Share Posted July 13, 2015 http://php.net/manual/en/function.html-entity-decode.php http://php.net/manual/en/function.htmlspecialchars-decode.php That was the first thing I tried -- I tried that, and it did not work: I tried both: echo html_entity_decode('''); echo htmlspecialchars_decode('''); I still get ' Quote Link to comment Share on other sites More sharing options...
Torrie Posted July 13, 2015 Author Share Posted July 13, 2015 Look into: http://www.w3schools.com/php/func_string_str_replace.asp That would only work for one individual string at a time echo str_replace(''',"'",$string); I want a php function that decodes all html characters. For some reason, nothing decodes the apostrophe ' Try it in your bash/terminal/putty and you'll see it don't work at all. Anyone? Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 13, 2015 Share Posted July 13, 2015 You need the ENT_QUOTES flag on, I believe. Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 13, 2015 Share Posted July 13, 2015 Yep, works here: php > var_dump(html_entity_decode(''', ENT_QUOTES) === "'"); bool(true)Would have tested earlier but I had to download php on this laptop. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.