unix cmd, variable as target instead of file

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
gizban
Forum Newbie
Posts: 1
Joined: Mon Jun 09, 2003 9:57 am

unix cmd, variable as target instead of file

Post 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?
sholdowa
Forum Newbie
Posts: 1
Joined: Tue Jun 10, 2003 3:03 am

Post by sholdowa »

Will the functionality provided by 'if' do what you want, or do you need to know what the differences are??
Tubbietoeter
Forum Contributor
Posts: 149
Joined: Fri Mar 14, 2003 2:41 am
Location: Germany

Post 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()
Post Reply