'Hide item from array

I am showing the product categories on the WooCommerce thank you page using this piece of code:

add_action( 'woocommerce_thankyou', 'show_product_category', 10, 1 );
function show_product_category ( $order_id ){
    // Get $product object from $order / $order_id
    $order = wc_get_order( $order_id );
    $items = $order->get_items();

    foreach ( $items as $item ) {
        $product = $item->get_product();

        print_r ($product->get_categories());

    }
}

The code above shows all categories, but I need to hide a specific category. Is it possible to hide a specific category by ID in the above code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source