Outputting a file into an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
misfitxnet
Forum Newbie
Posts: 14
Joined: Mon May 11, 2009 8:40 am

Outputting a file into an array

Post by misfitxnet »

I am trying to output a text file, that contains form information from a comment form.
I am using this php script

Code: Select all

 
<?php
                $delimiter="\t";
                $commenttext=file("d:\hshome\c239198\local54memberforum.com\info.txt");
               list($namedisp,$commentdisp)=explode($delimiter,$commenttext);
                echo $namedisp;
                echo $commentdisp;
 
                ?>
 
When i run the script, I get "Array" returned in the browser.
does anyone know why it will not return $namedisp, and $commentdisp? Here is a test sample of info.txt:

"hey hey hey hey "
Last edited by Benjamin on Tue May 12, 2009 4:25 pm, edited 1 time in total.
Reason: Added [code=php] tags.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Outputting a file into an array

Post by requinix »

array file ( string $filename [, int $flags= 0 [, resource $context ]] )

Reads an entire file into an array.
On the other hand, file_get_contents returns a string...
Post Reply