A proposal to add a native clamp() function to PHP that constrains a value within specified minimum and maximum bounds. The function returns the value if it's within range, or the nearest bound if outside. It supports mixed types (numbers, strings, DateTime objects) following PHP's comparison rules, throws ValueError for

3 Comments

Sort: