How can PHP be used to round numbers in intervals of 5 for graph scaling purposes?

When scaling numbers for a graph, it is often useful to round them to the nearest interval, such as intervals of 5. This can be achieved in PHP by using the ceil() and floor() functions to find the next highest and lowest multiple of 5, respectively. By rounding the numbers in this way, you can ensure that the graph scales nicely and is easy to read.

function roundToNearestIntervalOf5($number) {
    return round($number / 5) * 5;
}

// Example usage
$number = 23;
$roundedNumber = roundToNearestIntervalOf5($number);
echo $roundedNumber; // Output: 25