Question: I have no idea how to make this more efficient, and am working through coding challenges. Any hints?

The objective is to return the unique value in an array. 

[Test Conditions Which Code Fails](https://i.stack.imgur.com/1zZdq.png)

```
function solution($A) {

    foreach ($A as $key => $value) {

        $searchResults = array_keys($A, $value);

        //print "Total number of $value found in Array is: " . count($searchResults) . "\n";

        $checkNumber = count($searchResults);

        if ($checkNumber == 1) {

            //print "Unique value is: $value\n";
            return $value;

        }

        //print "\n";

    }

}

```

Answer: 
I found the above code was interfering with the operation of the plugin WooCommerce Advanced Free Shipping. I de-activated that plugin and deleted the code above. I then installed Advanced Flat Rate Shipping for Woocommerce and that plugin allowed me to set parameters that prevented the two product categories from being eligible for shipping method 2.
I made two important changes, changed the name of the function to avoid conflicts, and changed the method I'm removing for a specific test.

Note that the methods from what I saw come with lowercase letters, make sure your method is really the first capital letters this will make a difference;

Note that I left a comment where you can use to see the ids correctly.

Note that I put an if before unset to avoid php errors

```
function bz_specific_products_shipping_methods( $rates, $package ) {

   $product_ids = array( 149 ); // HERE set the product IDs in the array
   //$method_id = 'Express_Post:5'; // HERE set the shipping method ID
   $method_id = 'free_shipping:2'; // HERE set the shipping method ID
   $found = false;

   /*
    //please remove this comment to view all shipping methods and their information
   echo "<pre>";
   print_r( $rates );
   echo "</pre>";
   exit();*/

    // Loop through cart items Checking for defined product IDs
    foreach( $package['contents'] as $cart_item ) {
       if ( in_array( $cart_item['product_id'], $product_ids ) ){
           $found = true;
           break;
       }
    }

    if ( $found ){
        if( isset( $rates[$method_id] ) ){
            unset( $rates[$method_id] );
        }
    }

   return $rates;
}

//use the filter this is important
add_filter( 'woocommerce_package_rates', 'bz_specific_products_shipping_methods', 10, 2 );

```

This worked perfectly in my tests here, you may not be giving the name correctly or your woocommerce or php are out of date so the site message is experiencing difficulties or the loop with the white screen