Hi there
Plz help me out
I have 2 text files.
Text file 1 which contains :-
[{1,2, 3}, {x,y,z}, {4,5,6}, {a,b,c}, {7,8,9}]
Text file 2 which contains :-
[{x,y,z}, {a,b,c}]
Now, I want to delete elements which is present in text file 2 from text file 1 and write the output on a NEW text file.
NEW text file results :-
[{1,2, 3}, {4,5,6}, {7,8,9}]
Php program to manage txt file
By any chance are those files actually valid JSON? (You examples are almost valid JSON, but the text character values would have to be double-quoted for it to be valid JSON.)
If they were JSON, then it would be comparatively simpler, as you could parse each file into an array:
$my_array = json_decode(file_get_contents('/path/to/file.json'), true);
7 days later
If, as NogDog suggests, your files contain valid JSON, you could read their contents into two vars and perhaps use the array_diff function.