Get the brightness of a color in php

Get the brightness of a color in php

With this function it is possible to decide the font color based on a variable background colour.