Title: PHP Warning: array_merge(): Expected parameter 1 to be an array, null given
Last modified: November 4, 2020

---

# PHP Warning: array_merge(): Expected parameter 1 to be an array, null given

 *  Resolved [geoj](https://wordpress.org/support/users/georgjoutras/)
 * (@georgjoutras)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-array_merge-expected-parameter-1-to-be-an-array-null-given/)
 * Getting this same error over and over on my site:
    [04-Nov-2020 05:12:40 UTC]
   PHP Warning: array_merge(): Expected parameter 1 to be an array, null given in/
   home/ylm7sm1a17rt/public_html/wp-content/plugins/code-snippets/php/snippet-ops.
   php(446) : eval()’d code on line 28
 * I think it points to a bad snippet (I have 3 activated, about 10 not activated).
   Don’t know which one…any help you can point me towards?
 * Thanks!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-warning-array_merge-expected-parameter-1-to-be-an-array-null-given%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-array_merge-expected-parameter-1-to-be-an-array-null-given/#post-13621390)
 * Hi!
 * That message is definitely coming from one of your snippets – one of the ones
   which is activated. I can’t give you the name of the one causing the problem,
   but I can tell you it’ll be the one with `array_merge` on line 28 of its code.
 * To narrow the list down, you can search for the text `array_merge` in the snippet
   search box.
 *  Thread Starter [geoj](https://wordpress.org/support/users/georgjoutras/)
 * (@georgjoutras)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-array_merge-expected-parameter-1-to-be-an-array-null-given/#post-13621913)
 * Figured it out. Bad array_merge funtion in one of the code snippets I added.
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-array_merge-expected-parameter-1-to-be-an-array-null-given/#post-13622026)
 * Good to hear that it’s sorted!
 *  Thread Starter [geoj](https://wordpress.org/support/users/georgjoutras/)
 * (@georgjoutras)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-array_merge-expected-parameter-1-to-be-an-array-null-given/#post-13622055)
 * Thanks for the quick reply. I have figured out it is the code to add a new report
   to the ORDERS tab.
 * Here is the code that is causing the issue.
 * add_filter( ‘woocommerce_admin_reports’, ‘bbloomer_admin_add_report_orders_tab’);
 * function bbloomer_admin_add_report_orders_tab( $reports )
    {
 * $tab_array = array(
    ‘sales_by_state’ => array( ‘title’ => ‘Sales by State via
   snippet’, ‘description’ => ”, ‘hide_title’ => true, ‘callback’ => ‘bbloomer_yearly_sales_by_state’),);
   $reports[‘orders’][‘reports’] = array_merge($reports[‘orders’][‘reports’],$tab_array);
 * return $reports;
    }
 * For the life on me, I can’t figure out why the array_merge is failing…any thoughts
   would be greatly appreciated!
 * -Georg
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-array_merge-expected-parameter-1-to-be-an-array-null-given/#post-13622536)
 * It’s possible that _sometimes_ the `$reports['orders']` variable is empty, or`
   $reports['orders']['reports']` is set to a different value.
 * You should be able to fix this by adding a line to check whether that element
   is set and an array near the top of the function, and exit the function if so:
 * `if ( ! isset( $reports['orders']['reports'] ) || ! is_array( $reports['orders']['
   reports'] ) return;`
 *  Thread Starter [geoj](https://wordpress.org/support/users/georgjoutras/)
 * (@georgjoutras)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-array_merge-expected-parameter-1-to-be-an-array-null-given/#post-13622805)
 * Thank you, Shea! That did the trick.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘PHP Warning: array_merge(): Expected parameter 1 to be an array, null
given’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [geoj](https://wordpress.org/support/users/georgjoutras/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-array_merge-expected-parameter-1-to-be-an-array-null-given/#post-13622805)
 * Status: resolved