How can I compare the transferred data? And remove duplicate data for ($ row = 2; $ row <= $ highestRow; $ row ++ ){
$ Val_1 = $ sheet-> getCellByColumnAndRow (0, $ row)-> getValue ();
$ Val_2 = $ sheet-> getCellByColumnAndRow (1, $ row)-> getValue ();
$ Val_3 = $ sheet-> getCellByColumnAndRow (2, $ row)-> getValue ();
$ Val_4 = $ sheet-> getCellByColumnAndRow (3, $ row)-> getValue ();
Echo"";
Echo"". $ Val_1 ."";
Echo"". $ Val_2 ."";
Echo"". $ Val_3 ."";
Echo"". $ Val_4 ."";
Echo"";
};
This is the retrieved table data.
$ Sqls = "select * from bm_excell_content ";
$ Commands = $ connection-> createCommand ($ sqls );
$ Results = $ commands-> queryAll ();
Foreach ($ results as $ key => $ val ){
$ Values = $ val ['username'];
Echo"$ Values";
};
This is the imported database data.
How can we compare the two data?
Reply to discussion (solution)
Loop comparison, js code implementation
Save $ val_1 to the array $ arr1, save $ val ['username'] to the array $ arr2, and calculate the difference set $ arr = array_diff ($ arr2, $ arr1 );
$ Arr is the name of the person that exists only in the database and does not exist in the table.
Save $ val_1 to the array $ arr1, save $ val ['username'] to the array $ arr2, and calculate the difference set $ arr = array_diff ($ arr2, $ arr1 );
$ Arr is the name of the person that exists only in the database and does not exist in the table.
How do you assign values to the array for the data that I call out like this? thank you!
Loop comparison, js code implementation
The answer is too general.
The problem has been solved, but it has not been solved according to the opinions of all friends.