如何检测重复的 php 数组
我有这个数组:-
Array ( [0] => Prefectorial Board/Prefect/2011 [1] => Prefectorial Board/Head Prefect/2011 [2] => Class Positions/Head Prefect/2011 [3] => Prefectorial Board/Head Prefect/2011 )
如何检测这个数组是否有重复值,我希望参与者重新填写他的数据。
我尝试使用此方法来检测:-
$max = max(array_values($lr_str));
$keys = array_keys($lr_str, $max);
但它似乎对我不起作用。
对此有什么想法吗?
感谢您的提前。
I have this array:-
Array ( [0] => Prefectorial Board/Prefect/2011 [1] => Prefectorial Board/Head Prefect/2011 [2] => Class Positions/Head Prefect/2011 [3] => Prefectorial Board/Head Prefect/2011 )
How to detect this array have duplicate value and I want the participant to re-fill in his data.
I have try to use this method to detect:-
$max = max(array_values($lr_str));
$keys = array_keys($lr_str, $max);
but it seem like not work for me.
any idea on this?
thanks for advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道我是否理解正确,但您可以使用以下方法测试数组是否有重复值:
I do not know if I understand you correctly, but you can test the array has duplicated values by using this:
您是否在寻找array_unique?
Are you looking for array_unique?
您可以使用 array_unique() 删除重复值。如果没有删除任何值,则返回的数组应具有与原始数组相同的项目数:
You can use array_unique() to remove duplicate values. If no values were removed then the returned array should have the same number of items as the original: