1
print_r($ jobtypes)给我一个数组。数组包含重复的元素。我想删除重复项。这是一个阵列删除多维数组中的重复项
Array
(
[0] => stdClass Object
(
[term_id] => 40
[name] => Babysitting
[slug] => babysitting
[term_group] => 0
[term_taxonomy_id] => 40
[taxonomy] => job_listing_type
[description] =>
[parent] => 0
[count] => 3
)
[1] => stdClass Object
(
[term_id] => 43
[name] => Lawn Mowing
[slug] => lawn-mowing
[term_group] => 0
[term_taxonomy_id] => 43
[taxonomy] => job_listing_type
[description] =>
[parent] => 0
[count] => 3
)
[2] => stdClass Object
(
[term_id] => 39
[name] => Leaf Raking
[slug] => leaf-raking
[term_group] => 0
[term_taxonomy_id] => 39
[taxonomy] => job_listing_type
[description] =>
[parent] => 0
[count] => 2
)
[3] => stdClass Object
(
[term_id] => 41
[name] => Pet Sitting
[slug] => pet-sitting
[term_group] => 0
[term_taxonomy_id] => 41
[taxonomy] => job_listing_type
[description] =>
[parent] => 0
[count] => 3
)
[4] => stdClass Object
(
[term_id] => 42
[name] => Plant Watering
[slug] => plant-watering
[term_group] => 0
[term_taxonomy_id] => 42
[taxonomy] => job_listing_type
[description] =>
[parent] => 0
[count] => 2
)
[5] => stdClass Object
(
[term_id] => 44
[name] => Snow Shoveling
[slug] => snow-shoveling
[term_group] => 0
[term_taxonomy_id] => 44
[taxonomy] => job_listing_type
[description] =>
[parent] => 0
[count] => 5
)
[6] => stdClass Object
(
[term_id] => 40
[name] => Babysitting
[slug] => babysitting
[term_group] => 0
[term_taxonomy_id] => 40
[taxonomy] => job_listing_type
[description] =>
[parent] => 0
[count] => 3
[filter] => raw
)
)
如何删除重复项。我这种情况下
[name] => Babysitting
[slug] => babysitting
[term_group] => 0
[term_taxonomy_id] => 40
[taxonomy] => job_listing_type
[description] =>
[parent] => 0
[count] => 3
[filter] => raw
是两倍。我用
$jobtypes= array_map("unserialize", array_unique(array_map("serialize", $jobtypes)));
但不工作。谢谢
是什么语言?请添加标签。 – zishe
其php语言 – Riz
数据从哪里来?如果它来自数据库,则应该编写查询,以便重复结果不包含在结果中。另外,你在问之前是否(使用搜索)(https://stackoverflow.com/search?q=%5Bphp%5D+array+remove+duplicates)?有很多[问题](https://stackoverflow.com/questions/3579749/removing-duplicates-from-an-array)基本上要求同样的事情。 –