Added another PHP implementation by @checkdomain