I am trying to get POST
data based on a query, but I get duplicate results. I tried sort regular but still it shows many duplicates. What should I do?
My code (as shown below) prints repeated object IDs in the foreach
loop. Here, object_id = 2423
repeats. I want to keep one and delete the other other.
$vbn = $wpdb->get_results($query_cat_filter);
$bbc = array_unique($vbn, SORT_REGULAR);
foreach( $bbc as $cOM){
print_r($bbc);
}
Output:
Array
(
[0] => stdClass Object
(
[object_id] => 2415
[term_taxonomy_id] => 242
[term_order] => 0
)
[1] => stdClass Object
(
[object_id] => 2423
[term_taxonomy_id] => 242
[term_order] => 0
)
[2] => stdClass Object
(
[object_id] => 2423
[term_taxonomy_id] => 312
[term_order] => 0
)
)
How can I remove these duplicate values?