PHP Application

Status
Not open for further replies.

tavilach

In Runtime
Messages
134
I just had a really cool idea for a PHP application, but I don't know how to do two things:

1) Compare two files for equality.

2) Saving a web page as a file (like what you do in IE, when you click "Save As...-->Web Archive"--it saves the current state of the page as a .mht file) using PHP. In other words, giving PHP a web address, and letting it save the state of that address.

Any help will be most appreciated!
 
Actually, using PHP to save the source code, instead of saving the .mht file, should also work...but, again, I don't know how to do that.
 
php file compare...

About comparing 2 files, you can open each file, read character for character and compare them.

here is some code I have to read a file, I'm sure you can tweak it to fit your needs

function FileCompare() {

$file_data1 = fopen ("/path_to_file/file1.txt", "r");
$file_data2 = fopen ("/path_to_file/file2.txt", "r");

while (!feof ($file_data)) {
$record = fgets($file_data);
$ra = split( ',', $record);
//open other file and read/compare the characters

}
fclose($file_data);
}
 
Reading character for character looking for differences will put some load on the server... and it will end up being VERY slow if your file is of reasonable size...
 
yes and no...

I have imported a flat file into a database over the web very quickly. The file size was about 4.5 meg and takes less than a minute or 2.

This is reading line by line, though.. nonetheless, importing 25,000 records into a db from a flat file is pretty quick.
This is even doing a little logic/editing the data before it is inserted.

I was amazed at how fast it was.
Not sure how much time it would add, reading character by character.
 
Status
Not open for further replies.
Back
Top Bottom