Title: PHP Warning: max() in sorting.php
Last modified: April 29, 2021

---

# PHP Warning: max() in sorting.php

 *  Resolved [dingobytes](https://wordpress.org/support/users/dingobytes/)
 * (@dingobytes)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/php-warning-max-in-sorting-php/)
 * The following warning is being thrown if $order returns the empty array:
 * > PHP Warning: max(): Array must contain at least one element in /var/www/html/
   > wp-content/plugins/relevanssi/lib/sorting.php on line 314
 * Suggestion to resolve would be to set $max_key to zero before line 314 and then
   only use max($order) if $order is not empty.
 *  $max_key = 0;
    // Set the default values so that if the key is not found in 
   the array, it’s last. if (! empty($order)) $max_key = max( $order );

Viewing 1 replies (of 1 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/php-warning-max-in-sorting-php/#post-14382335)
 * Thanks, good catch. I’ll fix this in the next version.

Viewing 1 replies (of 1 total)

The topic ‘PHP Warning: max() in sorting.php’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

## Tags

 * [max](https://wordpress.org/support/topic-tag/max/)
 * [PHP Warning](https://wordpress.org/support/topic-tag/php-warning/)

 * 1 reply
 * 2 participants
 * Last reply from: [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/php-warning-max-in-sorting-php/#post-14382335)
 * Status: resolved