Just an FYI... I just ported a c# version of the Progress encode function to PHP. Both versions are public domain. Seems to work well.
PHP version
https://github.com/freakdaddy/php-progress-encode
c# version
https://github.com/pvginkel/ProgressEncode
PHP version
https://github.com/freakdaddy/php-progress-encode
c# version
https://github.com/pvginkel/ProgressEncode