RE: [PHP] .DAT file with PHP
| From: | Jabez Gan | Date: | Wed, 08 Mar 2006 18:45:33 +0000 |
| Subject: | RE: [PHP] .DAT file with PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231677@lists.php.net to get a copy of this message | ||
I use:
$frob = fopen('data/rob.dat','r');
if ($frob) {
while (!feof($frob)) {
$buffer = fgets($frob, 4096);
echo $buffer;
$glorp[] = $buffer; // places line in array
}
}
$read = array_reverse($glorp);
However, only "Array" text came out when I do an echo $read
What's wrong...?
Thanks for your patience!
-----Original Message-----
From: jblanchard@pocket.com [mailto:jblanchard@pocket.com]
Sent: Wednesday, March 08, 2006 11:50 PM
To: mingteikg@blizhosting.com; phpnet@blizhosting.com;
php-general@lists.php.net
Subject: RE: [PHP] .DAT file with PHP
[snip]
Sorry im new but, how do we read from a file to an array? I've studied C but
not with PHP and it's not working for me... Suggestions?
[/snip]
First, read and understand, as much as possible, TFM. It should go something
like this
$foo = fopen("my.dat", "r");
while(!feof($foo)){
$bar = fgets($foo, 4096); // gets a line hopefully
$glorp[] = $bar; // places line in array }
Once you have done this look at http://www.php.net/array for
all of the
things that you can do with the $glorp array
y
Attachment: [application/x-pkcs7-signature] smime.p7s
Attachment: [application/x-pkcs7-signature] smime.p7s