ShoeLace1291 Posted October 16, 2010 Share Posted October 16, 2010 I'm using a PHP foreach loop to set Javascript array values from PHP array values The problem is that some of the array values contain double quotes(") so it compromises the JS script. Is there a PHP function that automatically escapes each double quote in a given string? Link to comment https://forums.phpfreaks.com/topic/216040-escape-quotes-function/ Share on other sites More sharing options...
joel24 Posted October 17, 2010 Share Posted October 17, 2010 addslashes() Link to comment https://forums.phpfreaks.com/topic/216040-escape-quotes-function/#findComment-1122855 Share on other sites More sharing options...
Pikachu2000 Posted October 17, 2010 Share Posted October 17, 2010 addslashes() escapes more than just double quotes. You're probaly going to need to use str_replace(). Link to comment https://forums.phpfreaks.com/topic/216040-escape-quotes-function/#findComment-1122857 Share on other sites More sharing options...
Mchl Posted October 17, 2010 Share Posted October 17, 2010 you might want to use json_encode to convert PHP array to a JS array. Link to comment https://forums.phpfreaks.com/topic/216040-escape-quotes-function/#findComment-1122959 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.