在PHP中将小时+分钟的文本字符串转换为舍入的小数小时[重复]

This question already has an answer here:

I have a text-string 1 hour 43 mins

How can I convert this to output 1.75 using PHP?

(and this be true for all other possibilities, rounding to nearest .25 hours)

</div>

You take the hours, store it in a variable called hours. Take the minutes, device them by 60, and do a simple addition.

Take care of the case where minutes = 0, because it will throw an exception since you cannot divide by 0