Sort the two groups of numbers as required

Source: Internet
Author: User
Sort the two groups of numbers as required. $ A213, 856,89, 63,64, 123,58, 88,127; $ b34, 769,234,856,235, 92,65, 88; can also be used as a set of data processing: $ a213, 856,89, 63,64, 123,58, 88,127, 34,769,234,856,235, 92,65, 88; two groups of numbers are required to obtain the final results 856,88, and 2. the numbers are sorted as required.
$ A = '2014, 89, 213,856, 64, 88,127 ';
$ B = '2017, 92,65, 88 ';

It can also be processed as a set of data words:
$ A = '2014, 89, 213,856, 64, 88,127, 34,769,234,856,235, 88 ';


Obtain the final result 856,88, random ,89, 63,64, 123,58, 127,34, 769,234,235, 92,65 according to the number of two groups.

That is, for the number of two groups, duplicate arrays are arranged at the beginning of the order of appearance, and the remaining non-repeated arrays are arranged in the original order.


Remove duplicate values from a group of numbers, and sort other values in the original order.

$ A = '23 ';

Result, 68

------ Solution --------------------
The second simple point
$ A = array );
Print_r (array_unique ($ ));

First Complex
$ A = array (213,856, 64,123, 127 );
$ B = array (34,769,234,856,235, 65, 88 );
$ A1 = array_values (array_intersect ($ a, $ B ));
$ A2 = array_values (array_diff ($ a, $ a1 ));
$ A3 = array_values (array_diff ($ B, $ a1 ));
Print_r (array_merge ($ a1, $ a2, $ a3 ));

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.