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 Link to comment https://forums.phpfreaks.com/topic/297272-decoding-help/ 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 Link to comment https://forums.phpfreaks.com/topic/297272-decoding-help/#findComment-1516185 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 Link to comment https://forums.phpfreaks.com/topic/297272-decoding-help/#findComment-1516186 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 ' Link to comment https://forums.phpfreaks.com/topic/297272-decoding-help/#findComment-1516187 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? Link to comment https://forums.phpfreaks.com/topic/297272-decoding-help/#findComment-1516188 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. Link to comment https://forums.phpfreaks.com/topic/297272-decoding-help/#findComment-1516189 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. Link to comment https://forums.phpfreaks.com/topic/297272-decoding-help/#findComment-1516191 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.