[英]Trying to save each array to a txt file using php
<?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 =>设置文件名。 然后将[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);
?>
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);
}
此代码;
那有意义吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.