Jump to content

make a tab delimited file from array or object


severndigital

Recommended Posts

ok .. so I have this object and I want to make a tab delimited text file from it.

 

here's what I have so far.

 

function create_tab_file_from_object($the_object)
{
       $string = '';
       foreach($the_object as $val)
      { 
              $string .= $val.'\t';
      }
       //drop last tab
       $string = substr($string,0,-2);
       filename = 'test_file_pickup.txt';
$fp = fopen('/filepath/'.$filename,'w');
fwrite($fp,$string);
fclose($fp);
}

 

when i run this i get a text file that looks something like this

field1\tfield2\tfield3\t ... and so on.

 

How do I get php to make an actual tab delimited file I can open in notepad or excel or whatever..

 

Thanks in advance,

C

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.