Query the same value of data in the array,

Source: Internet
Author: User
Query the same value of data in the array! There are now three arrays $ data1 = array (& #39;, & #39;, & #39;, & #39 ;, & #39; 1, 2, 3, 4, 5, 8 & #39;, & #39; 1, 2, 3, 4, 5. query the same data value in the array for help!
There are now three arrays $ data1 = array ('1, 6', '1, ', '1, 8 ', '1, 2, 3, 4, 5, 9 ');
$ Data2 = array );
$ Data3 = array );

At the same time, the array $ data1 already exists in the database hmk.
The format is as follows:
L1 l2 l3 l4 l5 l6
1 2 3 4 5 6
1 2 3 4 5 7 ....

Now I want to add the field data2 data3 to HMK to store the number of times each record appears in $ data2 and $ data3. Is there any good method?

Should I perform operations in the array and store the results to the database, or should I perform operations directly in the database? Please help me !~~ Thank you!

------ Solution --------------------
PHP code
  $value) {    $data1[$key].=','.count(array_intersect(explode(',',$value),$data2));    $data1[$key].=','.count(array_intersect(explode(',',$value),$data3));}print_r($data1);

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.