Re: Writing to files

From: Date: Mon, 14 May 2001 14:34:08 +0000
Subject: Re: Writing to files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-52703@lists.php.net to get a copy of this message
On Mon, May 14, 2001 at 03:05:30PM +0100, Tarrant Costelloe wrote: > What's the most basic syntax for writing to a text file using PHP. I would > like to store some variables in one and then retrieve them a later stage...? This will append This is pretty basic to the end of the file instead of overwriting the file. <?php $basic = fopen("basic.txt", "a+"); fputs($basic, "This is pretty basic\n"); fclose($basic); ?> It is really easy to read in the entire file into an array. Probably not very efficient, but will get you started quickly. <?php $prettyBasic = file("basic.txt"); for($i = 0; $i < sizeof($prettyBasic); $i++) { echo "$prettyBasic[$i]<br>"; } ?> Search the online manual for more information on these functions. > > Taz > > -- > 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 > -- Jason Stechschulte jpstech@unoh.edu -- If I don't document something, it's usually either for a good reason, or a bad reason. In this case it's a good reason. :-) -- Larry Wall in <1992Jan17.005405.16806@netlabs.com>

« previous php.general (#52703) next »