How to remove identical elements from an array in php
How to remove identical elements from an array? It is written like this in the php manual
array_unique (PHP 4 >= 4.0.1)
array_unique -- remove duplicate values in the array
Description
array array_unique (array array)
array_unique() accepts array as input and Returns a new array with no duplicate values.
Note that the key name remains unchanged. array_unique() sorts the values first as strings, then retains only the first encountered key for each value, and then ignores all subsequent keys. This does not mean that the first occurrence of the same value in an unsorted array will be preserved.
Note: Two units are considered the same if and only if (string) $elem1 === (string) $elem2. That is, when the expressions of the strings are the same.
The first unit will be retained.
Example 1. array_unique() Example
[php]
$input = array ("a" => "green", "red", "b" => "green", "blue", " red");
$result = array_unique ($input);
print_r($result);
?>
[/php] Please indicate the source for reprinting: How to remove identical elements from an array in php

Hot AI Tools

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

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)
