Hi coders,
i’m having a problem trying to escape commas in my php script that generates products for use in my ecommerce site. I’ve tried all the usual suspects like , enclosing the string in single quotes and the commas in double quotes but all to no avail. I would really appreciate some help. The script parses a csv of my configurable products and outputs all variations. The problem is at the end of the line where $data[76] would be, and reads “size,paper,framing”. Thanks in advance.
[php]echo file_put_contents($file, “admin” . “,” . “base” . “,” . $data[2] . “,” . “15.00” . “,” . “Image Options” . “,” . “configurable” . “,” . $data[6] . “,” . “1” . “,” . $data[8] . “,” . “/” . $data[2] . “.png” . “,” . “/” . $data[2] . “.png” . “,” . “/” . $data[2] . “.png” . “,” . $data[12] . “,” . $data[13] . “,” . $data[14] . “,” . $data[15] . “,” . $data[16] . “,” . “No Layout Updates” . “,” .“Product Info Column”. “,” . “No” . “,” . $data[20] . “,” . $data[21] . “,” . $data[22] . “,” . “Enabled” . “,” . “None” . “,” . “” . “,” . “4” . “,” . “Yes” . “,” . “No” . “,” . “X-Small” . “,” . “Satin” . “,” . “No Frame” . “,” . $data[32] . “,” . $data[33] . “,” . $data[34] . “,” . $data[35] . “,” . $data[36] . “,” . $data[37] . “,” . $data[38] . “,” . $data[39] . “,” . $data[40] . “,” . $data[41] . “,” . $data[42] . “,” . “0” . “,” . “0” . “,” . “1” . “,” . “0” . “,” . “0” . “,” . “1” . “,” . “1” . “,” . “1” . “,” . “0” . “,” . “1” . “,” . “1” . “,” . $data[54] . “,” . $data[55] . “,” . “1” . “,” . “0” . “,” . “1” . “,” . “0” . “,” . “1” . “,” . “0” . “,” . “1” . “,” . “0” . “,” . $data[64] . “,” . “0” . “,” . “configurable” . “,” . $data[67] . “,” . $data[68] . “,” . $data[69] . “,” . $data[70] . “,” . $data[71] . “,” . “13” . “,” . “9.5” . “,” . “0.016” . “,” . “no” . “,” . “size,paper,framing”. “\r\n”, FILE_APPEND);[/php]
holy crap that’s a long string on a single line!
For starters let’s simplify the string a bit, which may also solve you problem in doing so.
Why do this;
“15.00” . “,” . “Image Options” . “,” . “configurable” . “,”
when you can do this?
"15.00, Image Options, configurable, "
Avoid concatenating literal strings when they can be rolled into one literal string.
nevermind, i seemed to have fixed it bu using ‘“size,paper,framing”’.!