Re: storing arrays

From: Date: Sun, 17 Feb 2002 14:20:06 +0000
Subject: Re: storing arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-85104@lists.php.net to get a copy of this message
----- Original Message ----- From: "Clark" <wiseguy316@netzero.com> To: <php-general@lists.php.net> Sent: Sunday, February 17, 2002 3:15 AM Subject: [PHP] storing arrays > Two questions: > > 1) Is it possible to write an array to a file? not direct, use: $fp = fopen("/my/file", "w"); foreach($filearray as $row) fputs($fp, $row."\n"); fclose($fp); > 2) Is it possible to specify the name of the key to each item of an > array when you get the array using file(). not direct, use: $keys = array("first", "second", "third", "fourht"); $filearray = file("/my/file"); for($x = 0; $x < count($filearray); $x++) $newfilearray[$keys[$x]] = $filearray[$x]; $filearray = $newfilearray; i think only a write version of file could be a useful function for php... mvgr, Joffrey van Wageningen -- .-[ Joffrey van Wageningen | WoLFjuh | joffrey@ne2000.nl ]-------------- | Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue | PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863 | * We demand guaranteed rigidly defined areas of doubt and uncertainty. | -- Douglas Adams

« previous php.general (#85104) next »