Warning: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in C:\wamp\www\test.php on line 71 -
i seek convert csv file tsv using below code.
in csv first word has no value. when run code generate tsv file correctly , gives above error. please help
thanks
$myfile = "file path"; function convert($filename) { if(@$fh_in = fopen("{$filename}.csv","r")) { $fh_out = fopen("{$filename}.tsv","a"); while(!feof($fh_in)) { $line = array(); $line = fgetcsv($fh_in,1024); fwrite($fh_out,implode("\t",$line)."\n"); } fclose($fh_in); fclose($fh_out); } else { echo "file doesn’t exist\n"; homecoming false; } echo "conversion completed!\n"; homecoming true; } convert($myfile);
according php manual, implode can be
string implode ( string $glue , array $pieces ) string implode ( array $pieces )
so in case if $line
empty execute sec prototype , consider \n
$pieces wrong. check value in $line
before calling implode
arguments warnings implode
No comments:
Post a Comment