iceblox Posted August 10, 2008 Share Posted August 10, 2008 Hi All, I have a script which uploads a CSV feed, the issue is that the feed text contains commas. I have been told the best way to do this is to add slashes? How would i add this to my script. This is line i believe it needs to be added too. $cols = explode(',', trim($line)); Thanks in advance Link to comment https://forums.phpfreaks.com/topic/119015-add-slashes/ Share on other sites More sharing options...
Barand Posted August 10, 2008 Share Posted August 10, 2008 Either use a delimiter other than comma in the CSV [pre] 1|field2|text,with comma|more text [/pre] or enclose text items in ".." [pre] 1,"field2","text,with comma","more text" [/pre] EDIT: Nearly forgot, use fgetcsv() to read the data, not explode, then you can specify the delimiter and quotes Link to comment https://forums.phpfreaks.com/topic/119015-add-slashes/#findComment-612843 Share on other sites More sharing options...
iceblox Posted August 10, 2008 Author Share Posted August 10, 2008 Thanks for that Barrand, All sorted ;0) One more for you if you dont mind.. The script i have replaces data in the feed for a a number which is defind within the feed. I was told that if there was a string i wanted to replace i could do this for example.. If I have "http://www.url.com/id=xxxx" and i want to replace "xxxx" for "4444" i was told to do this "xxxx|1" => "4444" But this isnt working. Any ideas? Link to comment https://forums.phpfreaks.com/topic/119015-add-slashes/#findComment-612846 Share on other sites More sharing options...
Barand Posted August 10, 2008 Share Posted August 10, 2008 $str = str_replace ('xxxx', '4444', "http://www.url.com/id=xxxx"); Link to comment https://forums.phpfreaks.com/topic/119015-add-slashes/#findComment-612958 Share on other sites More sharing options...
iceblox Posted August 10, 2008 Author Share Posted August 10, 2008 Does the http://www.url.com/id=xxxx bit have to match exactly for it to work? As mine is a data feed the bit after that in the same url is constantly changing? Thanks for the help Link to comment https://forums.phpfreaks.com/topic/119015-add-slashes/#findComment-612980 Share on other sites More sharing options...
Barand Posted August 10, 2008 Share Posted August 10, 2008 the "xxxx" needs to match Link to comment https://forums.phpfreaks.com/topic/119015-add-slashes/#findComment-613002 Share on other sites More sharing options...
iceblox Posted August 10, 2008 Author Share Posted August 10, 2008 Hmm, So i added this to my array, '!!!id!!!', '52297', "http://www.awin1.com/awclick.php?mid=2040&id=!!!id!!!"); but this is what it is doing to my url.. http://www.awin1.com/awclick.php?mid=2!!!id!!!4!!!id!!!&id=!!!id!!! Am I doing something wrong? Link to comment https://forums.phpfreaks.com/topic/119015-add-slashes/#findComment-613005 Share on other sites More sharing options...
iceblox Posted August 10, 2008 Author Share Posted August 10, 2008 Any ideas? Anyone? Link to comment https://forums.phpfreaks.com/topic/119015-add-slashes/#findComment-613048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.