在php网页中删除数组中重复的值的教程

 2022-03-19    645  

实例说明:

<!DOCTYPE html>
<html>
<body>
<?php
$a=array("a"=>"red","b"=>"green","c"=>"red");
print_r(array_unique($a));
?>
</body>
</html>

标签含义:

array_unique:函数用于移除数组中重复的值。如果两个或更多个数组值相同,只保留第一个值,其他的值被移除。

注释:被保留的数组将保持第一个数组项的键名类型。

源代码运行结果如下:

image.png


  •  标签:  
  • php
  •  

原文链接:https://77isp.com/post/770.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。