PHP 判断数组里的值是否有存在

 
一维数组检测
<?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 "没有重复的";
}
?>
上一篇:Verilog Tips and Interview Questions


下一篇:Blocking Cross Origin API request for /api/contents Creating Notebook Failed An error occurred while creating a new notebook.