$serialized = array_map('serialize', $targetArray); $unique = array_unique($serialized); return array_intersect_key($targetArray, $unique);