Skip to content

Instantly share code, notes, and snippets.

@resting
Created January 18, 2012 10:10
Show Gist options
  • Save resting/1632284 to your computer and use it in GitHub Desktop.
Save resting/1632284 to your computer and use it in GitHub Desktop.
PHP Save array to file
<?php
$data=array(
"name"=>"beckham",
"address"=>"LA"
);
$filename = 'data.txt';
$string = '';
foreach($data as $key => $val) {
$string .= "$key = $val\n";
}
file_put_contents($filename, $string);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment