Default php function that turns negative numbers in 0 April 6, 2023 by Tarik Try max($var,0), which will have the desired effect. See the manual page for more information.