PDA

View Full Version : Search and replace an SQL file


crighton
02-25-02, 20:32
Hi,

I need to perform a search and replace on a SQL file with rows as follows:

INSERT INTO productos VALUES("10272","El criticón","306","89,55","85,07","80,6","71,64","","","","","","","");

I need to be able to replace the commas in the prices (89,55 85,07 80,06 & 71,64) as this is causing errors in how the prices are displayed.

Obviously I can't do a standard search and replace because of the commas between Db fields. Can anyone suggest any pointers as to how I might go about this with PHP?

Even before search / replace issues can PHP read an external file?

Thanks in advance for all advice,

Gary

rwilkerson
03-09-02, 17:52
You can use regular expressions in conjunctions with the eregi_replace() function. Something like this may work for you ( or at least set you on the right track ).


$pattern = '\"[^,]*,[^"]*\"';
eregi_replace ( $pattern, '.', $string )