jmurch Posted March 26, 2008 Share Posted March 26, 2008 I have a need to do a ereg_replace on a bunch of strings as I am uploading a csv and the vendor can never have a single quote and has no escape character for them. So, I have a page with 20 os so variable that come from a form and go into a DB just fine but I need to reprocess them to creat the CSV for the vendor. Question 1: Is there a standard way of processing all of the vars through an array and dump each one out with a modified name after it is processed? Question 2: What is the proper syntax to escape the escape so it can be replaced. This only replaces the ' it doesn't replace the \ so when my input is \' my output is \`. It is supposed to be ' . $location_address_1 = ereg_replace("\'","`",$physical_location_address); TIA, Jeff Quote Link to comment Share on other sites More sharing options...
papaface Posted March 26, 2008 Share Posted March 26, 2008 I think you should look into magic quotes. Quote Link to comment Share on other sites More sharing options...
jmurch Posted March 26, 2008 Author Share Posted March 26, 2008 THanks for the suggestion but no on the majic quotes. I need a better solution. Per php.net: Warning This feature is DEPRECATED and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged. Jeff Quote Link to comment Share on other sites More sharing options...
jmurch Posted March 26, 2008 Author Share Posted March 26, 2008 This must be a common problem?? Quote Link to comment Share on other sites More sharing options...
effigy Posted March 26, 2008 Share Posted March 26, 2008 You can use array_map and str_replace. Quote Link to comment Share on other sites More sharing options...
jmurch Posted March 26, 2008 Author Share Posted March 26, 2008 Thanks Effigy that worked great. Is this a common workaround for majic quotes? There is no global replacement? Quote Link to comment Share on other sites More sharing options...
effigy Posted March 26, 2008 Share Posted March 26, 2008 I know there are settings to turn them on and off, and I've always left them off. I don't like the idea of configuring data modifications on a global scale. Quote Link to comment Share on other sites More sharing options...
jmurch Posted March 26, 2008 Author Share Posted March 26, 2008 Well majic quotes gone in PHP6 at least according to php.net. Thanks for the solution. Jeff 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.