一维数组检测
<?php
$a = array('as','ddf','ddf','as','qwe','wer','ert'); $res = array_unique($a); var_dump($res);die;
二维数组检测
<?php
$arr = array( array('a'=>'abc','aa'=>'asdas'), array('b'=>'cbd','bb'=>'asd'), array('d'=>'abw','cc'=>'aas'), array('c'=>'edf','dd'=>'aas'), ); $newarr = array(); foreach ($arr as $value) { foreach ($value as $v) { $newarr[] .= $v; } } $res = array_unique($newarr); if (count($newarr) != count($res)) { echo "有重复的"; }else{ echo "没有重复的"; }
?>