Php 如果满足特定条件,则删除多维数组中的特定数组。(富兰克林主题)
我试图做的是检查多维数组的特定值中是否存在重复项,然后删除具有重复项的嵌套数组。我试过这个Php 如果满足特定条件,则删除多维数组中的特定数组。(富兰克林主题),php,multidimensional-array,duplicate-removal,Php,Multidimensional Array,Duplicate Removal,我试图做的是检查多维数组的特定值中是否存在重复项,然后删除具有重复项的嵌套数组。我试过这个 $backerarr = $campaign->backers(); $unique = array(); for($i=0; $i<count($backerarr); $i++){ foreach($backerarr[$i] as $key=>$value){ if(in_array($value['post_author'], $unique)){
$backerarr = $campaign->backers();
$unique = array();
for($i=0; $i<count($backerarr); $i++){
foreach($backerarr[$i] as $key=>$value){
if(in_array($value['post_author'], $unique)){
unset($backerarr[$i]);
} else {
$unique[]=$value['post_author'];
}
}
}
上面是我必须操作的数组的一部分,在操作之后,只有一个$backerarr[I]应该存在,并且嵌套了相同的post_作者。可能的重复:您是否也可以发布数组的结构以及所需的输出??
array(3) {
[0]=> object(WP_Post)#495 (24) {
["ID"]=> int(824)
["post_author"]=> string(1) "1"
["post_date"]=> string(19) "2014-07-27 14:56:29"
["post_date_gmt"]=> string(19) "2014-07-27 14:56:29"
["post_content"]=> string(0) ""
["post_title"]=> string(0) ""
["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish"
["comment_status"]=> string(6) "closed"
["ping_status"]=> string(4) "open"
["post_password"]=> string(0) ""
["post_name"]=> string(3) "824"
["to_ping"]=> string(0) ""
["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2014-07-27 14:56:29"
["post_modified_gmt"]=> string(19) "2014-07-27 14:56:29"
["post_content_filtered"]=> string(0) ""
["post_parent"]=> int(728)
["guid"]=> string(64) ""
["menu_order"]=> int(0)
["post_type"]=> string(7) "edd_log"
["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw"
}......