How to Remove repeated items in a two-dimensional array-php Tutorial

Source: Internet
Author: User
How can I remove repeated items in a two-dimensional array? I have an array. the var_dump value is array (1) {[0] & gt; array (3) {[0] & gt; string (0) & quot; [1] & gt; string (4) & quot; Gumu & quot; [2] & gt; string (0) & quot; & quot ;}} how can I remove repeated items in a two-dimensional array added to this array?
I have an array. The value of var_dump is:
Array (1) {[0] => array (3) {[0] => string (0) "" [1] => string (4) "Gumu" [2] => string (0 )""}}
Now we want to add value to this array: $ info [] = $ insert;
After adding the item, I want to remove the repeated items and do not want two identical items.
I use array_unique ($ info). how can I remove duplicates?
That is, if there is another item {"", "Gumu ",""}

It can be determined when one or more items are added.

------ Solution --------------------
PHP code
Function array_multiunique ($ ar) {$ t = array_map ('serialize', $ ar); $ t = array_unique ($ t); return array_map ('unserialize ', $ t) ;}$ ar = array ("", "Gumu", ""), array ("", "Gumu ",""),); print_r (array_multiunique ($ ar ));

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.