Re: Opening a file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I did a

if ($lines === false) {
echo "lines is false";
}

like you suggested and it displays that text...but it still make no sense.
mypage.php and fruits.txt are in the same folder, on the same server.  There
isn't any permissions issues.

So, if mypage.php and fruits.txt are in the same folder, then $lines =
file("fruits.txt") should be valid.


On 9/5/07, Richard Davey <rich@xxxxxxxxxxxxx> wrote:
>
> Hi Dan,
>
> Wednesday, September 5, 2007, 3:24:43 PM, you wrote:
>
> > Opening this file is proving to be a pain. I have a folder that contains
> a
> > PHP page and a text file. I am trying to open the contents of the txt
> file
> > using file() but it keeps erroring out. Below is the code I'm using to
> try
> > and open it:
>
> > <?php
> > $fruit = "apple");
> > $lines = file("fruits.txt");
> > if (in_array($fruit,$lines))
> >   {
> >   $a = "Y";
> >   }
> ?>>
>
> > So, I'm setting my variable, opening my file as an array in $lines, then
> > checking to see if my variable is in the array, and if it is, assign a
> value
> > ot a new variable.  However, I am getting the following error:
>
> > PHP Warning: in_array()
> > [function.in-array<
> http://develop1/credit%20card%20processing/function.in-array>]:
> > Wrong datatype for second argument
>
> The call to file() has probably failed.
>
> Check to see if $lines === false, if so that is your problem. In which
> case you probably need to address the path to fruits.txt, or check
> file permissions.
>
> Cheers,
>
> Rich
> --
> Zend Certified Engineer
> http://www.corephp.co.uk
>
> "Never trust a computer you can't throw out of a window"
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux