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 Link to comment https://forums.phpfreaks.com/topic/98013-ereg_replace-for-all-vars/ 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. Link to comment https://forums.phpfreaks.com/topic/98013-ereg_replace-for-all-vars/#findComment-501492 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 Link to comment https://forums.phpfreaks.com/topic/98013-ereg_replace-for-all-vars/#findComment-501499 Share on other sites More sharing options...
jmurch Posted March 26, 2008 Author Share Posted March 26, 2008 This must be a common problem?? Link to comment https://forums.phpfreaks.com/topic/98013-ereg_replace-for-all-vars/#findComment-501519 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. Link to comment https://forums.phpfreaks.com/topic/98013-ereg_replace-for-all-vars/#findComment-501522 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? Link to comment https://forums.phpfreaks.com/topic/98013-ereg_replace-for-all-vars/#findComment-501525 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. Link to comment https://forums.phpfreaks.com/topic/98013-ereg_replace-for-all-vars/#findComment-501529 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 Link to comment https://forums.phpfreaks.com/topic/98013-ereg_replace-for-all-vars/#findComment-501531 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.