On Tue, 30 Nov 2004 17:45:37 -0000, "Alex Hopson"
<al************ *********@hotma il.com> wrote:
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_conten ts.
<?php
function readinfile($tem plate_file) {
# Variable Declaration
$i;
$output;
# Read file into temporary array
$temp = file($template_ file);
# Construct template output
for ($i=0; $i<count($temp) ; $i++) {
$output .= $temp[$i];
}
# Return results
return $output;
} // End readinfile
?>
Then:
$html = readinfile("/whatever/your/file/path/is/filename.html") ;
or
$html = readinfile("fil ename.html");
and of course, you can use a variable:
$source = "/whatever/your/file/path/is/filename.html";
$html = readinfile($sou rce);
--
gburnore@databa six dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
=============== =============== =============== =============== ===============
Want one? GET one!
http://signup.databasix.com
=============== =============== =============== =============== ===============