PHP two-dimensional array de-weight method

Source: Internet
Author: User
This article introduces the content of PHP two-dimensional array to the weight of the method, has a certain reference value, now share to everyone, the need for friends can refer to

1. First look at the two-bit array to be processed

Array ([    0] = = Array        (            [0] = 5            [1] = 6        )    [1] = = Array        (            [0] = 5        ) C10/>[2] = array        (            [0] = 5            [1] = 7        )    [3] = = Array        (            [0] = 5            [ 1] = 6            [2] =            [3] = +)        )

2. Convert the two-dimensional array to a one-dimensional array ($arr is your array above)

$result = Array_reduce ($arr, ' Array_merge ', Array ());

Look at the results.

Array (    [0] = 5    [1] = 6    [2] = 5    [3] = 5    [4] = 7    [5] = 5    [6] => ; 6    [7] =    [8] = 28)

3. Use array functions to remove duplicate values

$data = Array_unique ($result);
Array (    [0] = 5    [1] = 6    [4] = 7    [7] =    [8] = 28)

Complete!

If there is a more convenient way, please give more advice!

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.