reading an html file into a string

From: Alex Hopson (alex*under_score*hopson_at_hotmail.com)
Date: 11/30/04


Date: Tue, 30 Nov 2004 17:45:37 -0000

I'm trying to read an html file from my local server into a string, I'm
using the following code:

  $attfile = $attachment[$i]; //create filenames
   $file_name = basename ($attfile);
   $lines = file($attfile); //get file into array

   foreach ($lines as $line_num => $line) { //concatenate each line
        $fcontent.= $line;
   }

This should just load the file as an array then go through each line and add
it to the end of the $fcontent variable. It does this but on larger files
(4000+ lines of html) it stops part way through a line ver close to the end.
Basically it misses off about 10-15 lines at the end of the html file

I've increased the size of the file and it always seems to stop near the
end, but the line where it quit before is finished. So I guess it's not some
random character combination excaping it or reaching some kind of buffer
limit.

Does anyone have any ideas or know a simple script that will grab the
contents of an html file and put it into a string (not an array). I'm using
4.2.2 with no chance of upgrading so I can't use file_get_contents.

Thanks
Alex



Relevant Pages

  • Problems with getClass().getResource on the file path
    ... a string that describes the path to the html file. ... Is there a way to load the resources from the application working ... URL localUrl = getClass.getResource); ...
    (comp.lang.java.gui)
  • Re: How to link the image files on internet?
    ... not found" html file will be download and saved as JPG. ... How can I know the downloaded file is JPG, but not the "404" html file? ... > Public Function DownloadPicture(ByVal strURL As String) As String ... > Dim xmlhttp As Object ...
    (microsoft.public.access.modulesdaovba)
  • Re: Reading html into a source file
    ... > string in the array. ... The only problem is that the html file is not ... If you're running this as CGI under Apache this might be a problem. ...
    (comp.lang.perl.misc)
  • Re: How to replace string in a HTML file ??
    ... > I have an .ASP html file in a server. ... > and I know the name to match in the orginal HTML file. ... > These are string I want to change for playing directly from network ... If you don't know regular expression syntax, take some time to read perlre, ...
    (comp.lang.perl.misc)
  • Re: Replace unknow string varible in file.
    ... Imagine a html file full of 100's of these strings all mooshed ... Where the word 'MARKER' is a constant, it stay the same in each string ... unknown length. ... What I need to do it replace each instance of the random letter with a ...
    (comp.lang.python)