我想
将文件上传到ftp服务器
我怎么能用php做到这一点?
重要的部分是2,因为我很难找出用于修改链接的函数和正则表达式。下载和上传文件我可以弄清楚自己。
例如
输入:
ID, text1, link1, text2, text3, link2
1234, something, http://www.example.com/a/b/c, "lorem", "ipsum", http://www.example.com/image.gif
1235, something, http://www.example.com/dddd, "lorem", "ipsum", http://www.example.com/image.gif
1236, something, http://www.example.com/e/f/g/h, "lorem", "ipsum", http://www.example.com/image.gif
输出:
ID, text1, link1, text2, text3, link2
1234, something, http://www.example.com/a/b/c?tracking_code=1&tr2=2, "lorem", "ipsum", http://www.example.com/image.gif
1235, something, http://www.example.com/dddd?tracking_code=1&tr2=2, "lorem", "ipsum", http://www.example.com/image.gif
1236, something, http://www.example.com/e/f/g/h?tracking_code=1&tr2=2, "lorem", "ipsum", http://www.example.com/image.gif
答案 0 :(得分:1)
让我们假设您使用fgetcsv
$line = fgetcsv($fp);
$line[2] = $line[2] . "?tracking_code=1&tr2=2";
$data[] = $line;
......
foreach ($data as $line) {
fputcsv($fp, $line);
}
我发布的代码是抽象的,并假设您熟悉如何遍历csv文件。