Computer Forums

Search Tech-Forums.net

Member Login

Remember Me? Sign Up! | Forgot Password
 
 
Reply
Old 08-18-2003, 10:34 PM   #1 (permalink)
 
True Techie
Join Date: Jul 2003
Posts: 134
tavilach
Send a message via AIM to tavilach
Default PHP Application

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!
__________________
\"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world.\" -Archimedes
tavilach is offline   Reply With Quote
Old 08-18-2003, 10:54 PM   #2 (permalink)
 
True Techie
Join Date: Jul 2003
Posts: 134
tavilach
Send a message via AIM to tavilach
Default

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.
__________________
\"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world.\" -Archimedes
tavilach is offline   Reply With Quote
Old 08-18-2003, 10:57 PM   #3 (permalink)
Larry's Avatar
 
Join Date: May 2003
Posts: 1,541
Larry has disabled reputation
Default 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);
}
Larry is offline   Reply With Quote
Old 08-21-2003, 11:49 PM   #4 (permalink)
 
Newb Techie
Join Date: Aug 2003
Posts: 11
SDesigns
Send a message via AIM to SDesigns Send a message via Yahoo to SDesigns
Default

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...
SDesigns is offline   Reply With Quote
Old 08-22-2003, 12:08 AM   #5 (permalink)
 
Newb Techie
Join Date: Aug 2003
Posts: 8
casino
Default

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.
casino is offline   Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On