如何删除数组中的重复值 [英] How to remove duplicate values in an array

查看:108
本文介绍了如何删除数组中的重复值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个数组中删除重复值。

I want to remove duplicate values from an array.

下面是我的数组

$arr=array([0]=>123,[1]=>223,[2]=>323,[3]=>123,[4]=>223);

有关删除重复值,我用 array_unique()的功能,但它仍然显示了同样的阵列。

For removing duplicate values, I used array_unique() function, but it still shows the same array.

有没有解决这个问题的方法?

Is there any method to solve this problem?

推荐答案

使用 array_unique ()

<?php
$arr=array([0]=>123,[1]=>223,[2]=>323,[3]=>123,[4]=>223);
$result = array_unique($arr);
print_r($result);
?>

这篇关于如何删除数组中的重复值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆