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? Quote Link to comment Share on other sites More sharing options...
joel24 Posted October 17, 2010 Share Posted October 17, 2010 addslashes() Quote Link to comment 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(). Quote Link to comment 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. 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.