How can I compare the transferred data? And remove duplicate data.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.