Posted By

Tate on 11/09/09


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

xmartyxcorex
qubestream


Dump an array to a file


 / Published in: PHP
 

URL: http://www.sitepoint.com/forums/showthread.php?t=452250

  1. var_dump($GLOBALS);
  2. $data = ob_get_clean();
  3. $fp = fopen("textfile.txt", "w");
  4. fwrite($fp, $data);
  5. fclose($fp);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: kencyber on November 9, 2009

Why not just write the following:

fileputcontents ("textfile.txt", serialize($GLOBALS));

And then you can get it back by using:

$globals = unserialize(filegetcontents("textfile.txt"));

Posted By: kencyber on November 9, 2009

Sorry, my post got formatted - try that one more time:

Why not just write the following:

file_put_contents ("textfile.txt", serialize($GLOBALS));

And then you can get it back by using:

$globals = unserialize(file_get_contents("textfile.txt"));

You need to login to post a comment.