Page 1 of 1

Tab deliminated FPUTCSV() in php

Posted: Sun Jul 26, 2009 3:43 pm
by varma457
Hi,

I have a problem with tab deliminated fputcsv().

I tried it like..

$list=array("adsha,afjahf,asasdf",);
$file = fopen("contacts.csv","a");
foreach ($list as $line)
{
fputcsv($file, split("\t", $line));
}


But it is not working..

Re: Tab deliminated FPUTCSV() in php

Posted: Sun Jul 26, 2009 3:53 pm
by jackpf
Where are the tabs? That string looks comma delimited to me....

Also I think split() is deprecated. You should use preg_split() instead.

And how do you mean "not working"?

Re: Tab deliminated FPUTCSV() in php

Posted: Sun Jul 26, 2009 5:03 pm
by varma457
jackpf wrote:Where are the tabs? That string looks comma delimited to me....

Also I think split() is deprecated. You should use preg_split() instead.

And how do you mean "not working"?
what should I change for above code ..In order to get tab deliminated output

Re: Tab deliminated FPUTCSV() in php

Posted: Sun Jul 26, 2009 5:41 pm
by jackpf
Well, if you want each comma delimited word as a formatted csv line, then $list=array("adsha afjahf asasdf") and use preg_split('/\t/', $list);