Can you provide an example of how to create a custom function in PHP to display the number of days in a given month?

To create a custom function in PHP to display the number of days in a given month, you can utilize the `cal_days_in_month` function. This function takes the year and month as parameters and returns the number of days in that month. By creating a custom function that calls `cal_days_in_month`, you can easily retrieve the number of days in any given month.

function getDaysInMonth($year, $month) {
    return cal_days_in_month(CAL_GREGORIAN, $month, $year);
}

// Example usage
$year = 2022;
$month = 2; // February
echo "Number of days in February 2022: " . getDaysInMonth($year, $month);