RE: [PHP] Write an array to a file

From: Date: Tue, 29 Jan 2002 19:09:56 +0000
Subject: RE: [PHP] Write an array to a file
Groups: php.general 
Request: Send a blank email to php-general+get-82589@lists.php.net to get a copy of this message
Scott - You can just write it as a pipe-delimited file, write it to the file, and then read it back in. Use implode and explode: $company = array("Item 1", "Item 2", "Item 3", "Item 4"); #--------------------------------------------- # # Output array # $output_string = implode("|", $company); << write $output_string to a file >> # # Read array from file # if (!$file=fopen("file.txt", "r")) { echo "Error opening file"; } else { $input_string = fread($file,2048); } $company = explode("|", $input_string); #--------------------------------------------- -schnippy > -----Original Message----- > From: Scott Saraniero [mailto:Scottsar@aminternet.com] > Sent: Tuesday, January 29, 2002 12:34 PM > To: php-general@lists.php.net > Subject: [PHP] Write an array to a file > > > Hi, > > How do I write an array to a file? For example, I need to > write just this in > a file: > <?php $Company = array("Item 1", "Item 2", "Item 3", > "Item > 4", "Item 5",); > ?> > > I've been hung up for 2 days on this. Any help would be appreciated. > > Thanks, > Scott > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > >

« previous php.general (#82589) next »