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);