<?php
$file = fopen("test2.csv","r");
while(! feof($file)) {
print_r(fgetcsv($file));
$textfilename=[0].".txt";
file_put_contents ([1]);
}
fclose($file);
?>
这将采用类似
的数据Array (
[0] => name
[1] => download information
)
Array (
[0] => Sense and Sensibility Instant Digital Download
[1] => Please visit the following link to download your digital product: http://archive.org/download/0_sense_and_sensibility_librivox/Sense_Sensibility_1107_64kb_mp3.zip
)
并且对于每个0 =&gt;把它作为文件名。 然后将[1]存储到文件中并保存。但是我遇到了错误。
答案 0 :(得分:1)
你的意思是这样的? 尚未测试。
<?php
$file = fopen("test2.csv","r");
while(($line = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$textfilename=$line[0].".txt";
file_put_contents($textfilename, $line[1]);
}
fclose($file);
?>
答案 1 :(得分:0)
if (($handle = fopen("test2.csv", "r")) !== FALSE)
{
while (($line = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$textfile = $line[0] . ".txt";
file_put_contents($textfile, $line[1]);
}
fclose($handle);
}
此代码;
这有意义吗?