function to remove duplicate values of an array _php tutorial

Source: Internet
Author: User
The function of PHP to remove duplicate values of an array can also be understood as removing duplicate values of an array.

/*** the difference between the array and the Array_unique function: it requires Val to be a string, and this can be an array/object * * @param $arr the array to be drained * @param $reserveKey preserve the original key* @return array */function M_arrayunique ($arr, $reserveKey =false) {if (Is_array ($arr) &&!empty ($arr)) {foreach ($arr as $key = > $value) {$tmpArr [$key]=serialize ($value). ';} $TMPARR =array_unique ($TMPARR), $arr =array (), foreach ($tmpArr as $key + = $value) {if ($reserveKey) {$arr [$key]= Unserialize ($value);} else{$arr []=unserialize ($value);}}} return $arr;}

For how to remove the duplicate values of the two-dimensional array, you can refer to: PHP two-dimensional array to remove duplicate values of the method summary

The above is the function of removing the duplicate value of the array _php the contents of the tutorial, please follow topic.alibabacloud.com (www.php.cn) for more information!

http://www.bkjia.com/PHPjc/764186.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/764186. htmltecharticlephp functions that remove duplicate values from an array can also be understood as removing duplicate values of an array. /*** the difference between an array and a array_unique function: It requires Val to be a string, and this can be ...

  • Related Article

    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.