Argument #1 ($value) must contain at least one element

Description

max() and min() require at least one element in the array: otherwise, the returned value could be confused with NULL.

Example

<?php

max([]);

?>

Solutions

  • Check if the array has at least one argument before calling max() or min().

  • Add an element to the array before callign max(), and use it as a canary.