file comparision

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
swaruu
Forum Newbie
Posts: 2
Joined: Thu Aug 17, 2006 10:49 pm

file comparision

Post by swaruu »

how do i compare two files in php ? can anyone help me ?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

thallish
Forum Commoner
Posts: 60
Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark

Post by thallish »

you can use file() or file_get_contents(), and the compare the arrays or strings

dont know if this is the most effective way though

EDIT: Oren's response is better :lol:
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

md5_file is great for testing equality but not much else. What exactly is the comparison based on?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use filesize() before using md5_file(). Why spend time doing an md5 hash if they are different sizes. :P
Post Reply