note 98041 deleted from function.fwrite by danbrown

From: Date: Sat, 22 May 2010 16:47:40 +0000
Subject: note 98041 deleted from function.fwrite by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169516@lists.php.net to get a copy of this message
Note Submitter: nuit ---- i have been the reading the notice from chaly: it's far simpler to use the serialize function...i think there's a json function aswell: (simple example) <?php function save_array_to_file($filename,$b) { $file = fopen($filename,'w+'); fwrite($file,serialize($b)); fclose($file); } function read_array_from_file($filename) { return unserialize(file_get_contents($filename)); } $array = array('hallo', 'test' => 'noch ein test'); print_r($array); save_array_to_file('array.txt',$array); $arr2 = read_array_from_file('array.txt'); print_r($arr2); ?>

« previous php.notes (#169516) next »