Php 如何在多维3D数组中获得唯一值?
如何从多维数组中获取唯一值 $arr=数组 大堆 arrayavg, arrayresponsecnt, 其他=>array surveycomplete, , 大堆 arrayavg,响应, arrayresponsecnt, 其他=>array surveycomplete, , 大堆 美国广播公司阿拉亚夫, arrayresponsecnt,xyz, other=>array surveycomplete,是, , 大堆 arrayavg, arrayresponsecnt, 其他=>array surveycomplete, ; 回响Php 如何在多维3D数组中获得唯一值?,php,arrays,sorting,multidimensional-array,Php,Arrays,Sorting,Multidimensional Array,如何从多维数组中获取唯一值 $arr=数组 大堆 arrayavg, arrayresponsecnt, 其他=>array surveycomplete, , 大堆 arrayavg,响应, arrayresponsecnt, 其他=>array surveycomplete, , 大堆 美国广播公司阿拉亚夫, arrayresponsecnt,xyz, other=>array surveycomplete,是, , 大堆 arrayavg, arrayresponsecnt, 其他=>ar
我需要某种方法在上面的数组中找到唯一的值。有人能帮我吗?运行这个脚本,我想你会看到如何做你想做的事情
你试过什么吗?请。。。格式化该代码。是的,我一整天都很累。仍在尝试某种解决方案。@Manoranjan您必须批准挂起的编辑。@Manoranjan显示您当前的代码。很抱歉,我需要上面数组中的唯一值。若它出现,则第一个不应出现在下一个连续数组中。唯一的数组元素。
<?php
$arr = array(
array(
array("avg"),
array("responsecnt"),
"other" => array ("surveycomplete")
),
array(
array("avg","responsecnt"),
array("responsecnt"),
"other" => array ("surveycomplete")
),
array(
array("avg","abc"),
array("responsecnt","xyz"),
"other" => array ("surveycomplete", "yes"),
),
array(
array("avg"),
array("responsecnt"),
"other" => array ("surveycomplete"),
)
);
echo "<pre>";
print_r($arr);
for($i=0;$i<sizeof($arr);$i++){
for($j=0;$j<sizeof($arr[$i]);$j++){
for($k=0;$k<sizeof($arr[$i][$j]);$k++){
echo $arr[$i][$j][$k]."<br>";
}
}
for($l=0;$l<sizeof($arr[$i]["other"]);$l++)
{echo $arr[$i]["other"][$l]."<br>";}
}