Title: PHP 8 Fatal Error: array_diff() Argument #1 must be array
Last modified: February 25, 2026

---

# PHP 8 Fatal Error: array_diff() Argument #1 must be array

 *  Resolved [Fixmysite](https://wordpress.org/support/users/newtlabs/)
 * (@newtlabs)
 * [3 months, 1 week ago](https://wordpress.org/support/topic/php-8-fatal-error-array_diff-argument-1-must-be-array/)
 * Hi,
 * We encountered a fatal error when saving settings in the plugin under PHP 8.x.
 * Error message:
 * `Fatal error: Uncaught TypeError: array_diff(): Argument #1 ($array) must be 
   of type array, false given in /wp-content/plugins/searchpro/inc/helper-functions.
   php on line 1592`
 * The issue occurs inside the function:
 * `bwp_is_option_updated()`
 * Specifically this line:
 * `return !empty(array_diff($option_val, $urls_array));`
 * In some cases `get_option($option_name)` returns `false` (likely when the option
   does not yet exist), which causes `array_diff()` to throw a TypeError in PHP 
   8+.
 * As a temporary fix, we changed the line to:
 * `return !empty(array_diff(is_array($option_val) ? $option_val : [], $urls_array));`
 * This prevents the fatal error and ensures compatibility with PHP 8.
 * It may be worth updating the plugin to validate that `$option_val` is always 
   an array before calling `array_diff()` to avoid breaking admin pages under newer
   PHP versions.
 * Environment:
    - WordPress: Latest
    - PHP: 8.x
    - Plugin version: 3.1.17
 * Hope this helps.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Hamza Mairaj](https://wordpress.org/support/users/thevisionofhamza/)
 * (@thevisionofhamza)
 * [3 months, 1 week ago](https://wordpress.org/support/topic/php-8-fatal-error-array_diff-argument-1-must-be-array/#post-18835335)
 * Hey there,
 * Thanks for reporting the bug. We’ve added a fix in the latest version (v3.1.18).

Viewing 1 replies (of 1 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-8-fatal-error-array_diff-argument-1-must-be-array%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/searchpro/assets/icon-256x256.png?rev=2987386)
 * [BerqWP - Automatic WordPress Website Speed Optimization](https://wordpress.org/plugins/searchpro/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/searchpro/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/searchpro/)
 * [Active Topics](https://wordpress.org/support/plugin/searchpro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/searchpro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/searchpro/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Hamza Mairaj](https://wordpress.org/support/users/thevisionofhamza/)
 * Last activity: [3 months, 1 week ago](https://wordpress.org/support/topic/php-8-fatal-error-array_diff-argument-1-must-be-array/#post-18835335)
 * Status: resolved