pedantic formatting edit
splitting the library function from the example code so it can be used as a basic library
use the PHP 5.4 native method when it is available
gitignore editor backup files, etc. + gitattributes to make sure the files always check in with a known, fixed format irrespective of the current development platform
optimization: last round would be nil as it would be 'processing' past the end of the input, i.e. an empty char.