Page 1 of 1

unix cmd, variable as target instead of file

Posted: Mon Jun 09, 2003 9:57 am
by gizban
I’m trying to use the unix diff command “diff –u –0 file1 file2” using php. I can use this on 2 files that are currently in the directory, but I’d like to use the diff command on 2 variables instead of 2 files. Of course I could save the 2 variables as file then do the diff, but is there a more direct way to diff 2 variables in php instead of having to save them as files in the directory?

Posted: Tue Jun 10, 2003 3:03 am
by sholdowa
Will the functionality provided by 'if' do what you want, or do you need to know what the differences are??

Posted: Tue Jun 10, 2003 9:09 am
by Tubbietoeter
there is no such function, you have to implement your own ...

diff can only handle files.

you could also convert the variables into an array (split at blank) and then use array_diff()