note 98041 added to function.fwrite

From: Date: Sat, 22 May 2010 16:46:42 +0000
Subject: note 98041 added to function.fwrite
Groups: php.notes 
Request: Send a blank email to php-notes+get-169515@lists.php.net to get a copy of this message
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); ?> ---- Server IP: 217.160.235.204 Probable Submitter: 88.65.66.180 ---- Manual Page -- http://www.php.net/manual/en/function.fwrite.php Edit -- https://master.php.net/note/edit/98041 Del: integrated -- https://master.php.net/note/delete/98041/integrated Del: useless -- https://master.php.net/note/delete/98041/useless Del: bad code -- https://master.php.net/note/delete/98041/bad+code Del: spam -- https://master.php.net/note/delete/98041/spam Del: non-english -- https://master.php.net/note/delete/98041/non-english Del: in docs -- https://master.php.net/note/delete/98041/in+docs Del: other reasons-- https://master.php.net/note/delete/98041 Reject -- https://master.php.net/note/reject/98041 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169515) next »