Re: file( ) function

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

 



Mayank Maheshwary wrote:

> Hi,
> 
> I am facing some trouble with the file( ) function. I understand that it
> returns the contents of the file in an array. Also, I am able to print the
> lines using the echo function. However, whenever I try to compare the
> contents of an array using strcmp, or ==, the page simply keeps 'loading',
> instead of printing results.
> 
> The following is the code that I try:
> 
> $name = $_POST["filename"];
> $lines = file($name);
> $i = 0;
> $len = sizeof($lines);
> //echo $i;
> while($i < $len) {
>   //echo $lines[$i];
>   $temp = $lines[$i];
>   $temp = trim($temp);
>   //echo $temp;
>   if($temp1 == '--------------------------------------') {
>     echo $i;
>     return $i;
>   }
>   else
>     $i++;
> }
> 
> I think that the way the lines of the file are stored in the array may be
> the problem, but I do not know what I am supposed to change. Any help
> would be appreciated.
> 
> Thanks.
> 
> MM.

You seem to be aware of the fact that each line of the file is loaded into
an arry element with the newline still attached as you are using trim() to
clear white space from the start/end of the array element. For a second
test, maybe do a strlen on the array element and see if that tells you
anything.



Cheers
-- 
David Robley

Memory is a thing we forget with.
Today is Prickle-Prickle, the 13rd day of Confusion in the YOLD 3172. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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