At 1:31 PM -0700 8/30/01, Kyle Smith wrote:
>ok i have this code to do whats below, but its not working
>   <?php
>$fp = fopen("meh.txt","r");
>print "$fp[$i]";

That's because $fp is a file POINTER, not the actual contents of the 
file. You might have been thinking of the file() function, which 
sucks the entire contents of the file into an array...very wasteful, 
if all you need are the first few lines. What you want here is:

        $fp = fopen("meh.txt","r");
        print fread($fp, 4096);
        $fp = fopen("meh.txt","r");
        $FileArray[] = fread($fp, 4096);

        foreach($FileArray as $line)
        print $line;

The second parameter in the fread function is the maximum line 
length; normally, that would be set to ma number larger than the 
maximum line length you're likely to encounter (unless you have long 
lines, and only need the first few characters of that line). See:

Also, the line

        print "$fp[$i]";

isn't likely to work the way you expect; if $fp was an array, you'd 
get something like


as the printout, since the $i, in quotes, wouldn't be interpreted as 
an array index. Use something like

        print $fp[$i];
        print "Some text here ".$fp[$i]." more text here";


>Home of the burning lego man!
>ICQ: 115852509
>AIM: legokiller666

+------------------------ Open source questions? ------------------------+
| Steve Edberg                           University of California, Davis |
| [EMAIL PROTECTED]                               Computer Consultant |
|         |
+----------- -----------+

PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to