First attempt at building a PHP-ified version.