


PHP array function sequence array_unique() - remove duplicate element values ????in the array
Dec 28, 2016 pm 03:17 PMarray_unique() Definition and Usage
array_unique() function removes duplicate values ??from the array and returns the resulting array.
When the values ??of several array elements are equal, only the first element is retained and the other elements are deleted.
The key names in the returned array remain unchanged.
Syntax
array_unique(array)
Parameter Description
array Required. Specifies the input array.
Description
array_unique() first sorts the values ??as strings, then only retains the first encountered key name for each value, and then ignores all subsequent key names. This does not mean that the first occurrence of the same value in an unsorted array will be preserved.
Tips and Notes
Note: The returned array will retain the key type of the first array element.
Example
<?php $a=array("a"=>"Cat","b"=>"Dog","c"=>"Cat"); print_r(array_unique($a)); ?>
Output:
Array ([a] => Cat [b] => Dog )
For more php array function sequence array_unique() - removing duplicate element values ????in an array, please pay attention to the PHP Chinese website for related articles!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)