How to delete identical values ​​from php array

Guanhui
Release: 2023-02-28 22:06:02
Original
2072 people have browsed it

How to delete identical values ​​from php array

php array deletes the same values

In PHP, you can use the "array_unique()" function to remove duplicate values ​​in the array , the usage of this function is "array_unique($array)", its parameter $array represents the array from which duplicate values ​​are to be removed, and the return value of this function is the array after removing duplicate values.


array_unique example

 "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
Copy after login

Output result:

Array
(
    [a] => green
    [0] => red
    [1] => blue
)
Copy after login

The above is the detailed content of How to delete identical values ​​from php array. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!